小编Ben*_*ins的帖子

OS X - 无法启动Git:/ usr/bin/git可能Git可执行文件的路径无效

我在Android Studio中遇到此错误:

无法启动Git:/ usr/bin/git可能Git可执行文件的路径无效.

它为我提供了修复它的选项,它将我带到Android Studio中的区域来设置git的路径.我看到它已经设定

在/ usr/bin中/混帐

我检查了那条路径,那条路径确实是git可执行文件的路径.为什么Android Studio无法启动git?

编辑:当我尝试在Android Studio终端中使用git命令时,它说:

同意Xcode/iOS许可证需要管理员权限,请通过sudo以root身份重新运行.

git macos android-studio

110
推荐指数
8
解决办法
6万
查看次数

@viewChild不工作 - 无法读取未定义的属性nativeElement

我正在尝试访问本机元素,以便在单击另一个元素时专注于它(非常类似于html属性"for" - 因为不能在此类型的元素上使用.

但是我得到错误:

TypeError:无法读取未定义的属性"nativeElement"

我尝试console.log中的nativeElement,ngAfterViewInit()以便它被加载,但它仍然会抛出错误.

我还在click事件处理程序中访问nativeElement,这样我可以在单击另一个元素时聚焦该元素 - 这可能是什么在混淆它,因为它在视图加载之前编译?

例如:

ngAfterViewInit() {
    console.log(this.keywordsInput.nativeElement); // throws an error
}

focusKeywordsInput(){
    this.keywordsInput.nativeElement.focus();
}
Run Code Online (Sandbox Code Playgroud)

完整代码:

正在使用的html模板的相关部分:

<div id="keywords-button" class="form-group" (click)="focusKeywordsInput()">
    <input formControlName="keywords" id="keywords-input" placeholder="KEYWORDS (optional)"/>
    <div class="form-control-icon" id="keywords-icon"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

component.ts:

import { Component, OnInit, AfterViewInit, ViewChild, ElementRef } from '@angular/core';
import {  REACTIVE_FORM_DIRECTIVES, 
          FormGroup, 
          FormBuilder, 
          Validators,
          ControlValueAccessor
        } from '@angular/forms';
import { NumberPickerComponent } from './number-picker.component';
import { DistanceUnitsComponent } from './distance-units.component';
import { MapDemoComponent } from '../shared/map-demo.component';
import { AreaComponent …
Run Code Online (Sandbox Code Playgroud)

viewchild angular

29
推荐指数
5
解决办法
7万
查看次数

许多使用相同组件的模块会导致错误 - Angular 2

我有一个名为GoComponent的共享组件,我想在2个模块中使用:FindPageModule和AddPageModule.

当我在"FindPageModule"的声明和我的"AddPageModule"中添加它时,我收到一个错误:

find:21错误:(SystemJS)类型GoComponent是2个模块的声明的一部分:FindPageModule和AddPageModule!请考虑将GoComponent移动到导入FindPageModule和AddPageModule的更高模块.您还可以创建一个新的NgModule,它导出并包含GoComponent,然后在FindPageModule和AddPageModule中导入该NgModule.

所以我把它们从它们中取出并将它添加到AppModule声明中,它确实导入了FindPageModule和AddPageModule,并且在FindPageModule声明中使用"GoComponent"的组件中出现了一个名为"FindFormComponent"的组件中的错误:

zone.js:355 Unhandled Promise rejection: Template parse errors:
'go' is not a known element:
1. If 'go' is an Angular component, then verify that it is part of this module.
2. If 'go' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. (" style="height:64px;">
            <div style="position: relative; display: inline-block; width: 100%;">
                [ERROR ->]<go></go>
            </div>
        </div>
"): FindFormComponent@101:4 ; Zone: <root> ; Task: Promise.then ; Value: Error: Template parse errors:(…) …
Run Code Online (Sandbox Code Playgroud)

ng-modules angular

18
推荐指数
1
解决办法
2万
查看次数

Jasmine测试中的模板解析错误,但不是实际的应用程序

我开发了一个Jasmine规范来测试角度2分量MiddleRowComponent.当我运行jasmine测试时,它会给出以下错误:

zone.js:388 Unhandled Promise rejection: Template parse errors:
'circles' is not a known element:
1. If 'circles' is an Angular component, then verify that it is part of this module.
2. If 'circles' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("</div>
      <div class="col-md-10 col-sm-12 offset-md-1 flex-xs-middle" id="circles-div">
         [ERROR ->]<circles (onWordChanged)="onWordChanged($event)"></circles>
      </div>
      <div class="col-md-10 "): MiddleRowComponent@9:9
'custom-button' is not a known element:
Run Code Online (Sandbox Code Playgroud)

但是,如果我像往常一样在浏览器中运行我的Web应用程序,则不会发生错误.circles确实是模块的一部分.并且custom-button是导入的共享模块的一部分.这是module.ts:

    import { …
Run Code Online (Sandbox Code Playgroud)

jasmine angular

17
推荐指数
3
解决办法
9683
查看次数

模拟IMemoryCache与Moq抛出异常

我正试图IMemoryCache用Moq 嘲笑.我收到这个错误:

Moq.dll中出现"System.NotSupportedException"类型的异常,但未在用户代码中处理

附加信息:表达式引用不属于模拟对象的方法:x => x.Get <String>(It.IsAny <String>())

我的嘲弄代码:

namespace Iag.Services.SupplierApiTests.Mocks
{
    public static class MockMemoryCacheService
    {
        public static IMemoryCache GetMemoryCache()
        {
            Mock<IMemoryCache> mockMemoryCache = new Mock<IMemoryCache>();
            mockMemoryCache.Setup(x => x.Get<string>(It.IsAny<string>())).Returns("");<---------- **ERROR**
            return mockMemoryCache.Object;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

为什么我会收到这个错误?

这是测试中的代码:

var cachedResponse = _memoryCache.Get<String>(url);
Run Code Online (Sandbox Code Playgroud)

哪种_memoryCache类型IMemoryCache

我如何模拟_memoryCache.Get<String>(url)上面的内容并让它返回null?

编辑:我怎么做同样的事情,但为 _memoryCache.Set<String>(url, response);?我不介意它返回什么,我只需要将方法添加到mock中,这样它就不会在调用时抛出.

我试着回答这个问题的答案:

mockMemoryCache
    .Setup(m => m.CreateEntry(It.IsAny<object>())).Returns(null as ICacheEntry);
Run Code Online (Sandbox Code Playgroud)

因为在memoryCache扩展中它显示它CreateEntry在内部使用Set.但是"对象引用没有设置为对象的实例"是错误的.

c# unit-testing moq .net-core asp.net-core

16
推荐指数
3
解决办法
6388
查看次数

redux-observable你在预期的流中提供了'undefined'

我正在使用fbsdk在ajax请求中获取用户详细信息.所以在redux-observable史诗中这样做是有意义的.fbsdk请求的方式,它没有.map(),.catch()它需要成功和失败回调:

码:

export const fetchUserDetailsEpic: Epic<*, *, *> = (
  action$: ActionsObservable<*>,
  store
): Observable<CategoryAction> =>
  action$.ofType(FETCH_USER_DETAILS).mergeMap(() => {
    getDetails(store)
  })

const getDetails = store => {
  console.log(store)
  let req = new GraphRequest(
    '/me',
    {
      httpMethod: 'GET',
      version: 'v2.5',
      parameters: {
        fields: {
          string: 'email,first_name,last_name'
        }
      }
    },
    (err, res) => {
      if (err) {
        store.dispatch(fetchUserDetailsRejected(err))
      } else {
        store.dispatch(fetchUserDetailsFulfilled(res))
      }
    }
  )

  return new GraphRequestManager().addRequest(req).start()
}
Run Code Online (Sandbox Code Playgroud)

它给出了错误:

TypeError:您提供了"undefined",其中包含了一个流.您可以提供Observable,Promise,Array或Iterable.

如何从史诗中返回一个observable,以便这个错误消失?

尝试bindCallback从这个SO答案:

const …
Run Code Online (Sandbox Code Playgroud)

react-native react-redux react-native-fbsdk redux-observable

16
推荐指数
1
解决办法
1948
查看次数

插件/预设文件不允许导出对象,仅导出函数

更新react-native后我收到此错误"^0.56.0":

 bundling failed: Error: Plugin/Preset files are not allowed to export objects, only functions. In /Users/ben/vepo/frontend/node_modules/babel-preset-flow/lib/index.js
Run Code Online (Sandbox Code Playgroud)

我尝试做类似于最高投票答案的事情,而不是babel-preset-flow:

https://github.com/babel/babel-loader/issues/540

.babelrc:

"presets": ["react-native", "flow", "@babel/preset-flow"]
Run Code Online (Sandbox Code Playgroud)

的package.json

{
  "name": "vepo",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "rnpm": {
    "assets": [
      "./app/fonts"
    ]
  },
  "jest": {
    "preset": "react-native",
    "moduleNameMapper": {
      "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
      "\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"
    }
  },
  "dependencies": {
    "@babel/preset-flow": "^7.0.0-beta.52",
    "@babel/preset-react": "^7.0.0-beta.52",
    "babel-preset-react-native": "^4.0.0",
    "flow-typed": "^2.4.0",
    "generator-rn-toolbox": "^2.2.0",
    "imagemagick": "^0.1.3",
    "immutable": "4.0.0-rc.9",
    "metro-bundler": "^0.22.1",
    "native-base": …
Run Code Online (Sandbox Code Playgroud)

babel flowtype react-native babel-preset-env

15
推荐指数
3
解决办法
1万
查看次数

未处理的承诺拒绝:无法匹配任何路线

当我运行这个单元测试时:

it('can click profile link in template', () => {
    const landingPageLinkDe = linkDes[0];
    const profileLinkDe = linkDes[1];
    const aboutLinkDe = linkDes[2];
    const findLinkDe = linkDes[3];
    const addLinkDe = linkDes[4];
    const registerLinkDe = linkDes[5];
    const landingPageLinkFull = links[0];
    const profileLinkFull = links[1];
    const aboutLinkFull = links[2];
    const findLinkFull = links[3];
    const addLinkFull = links[4];
    const registerLinkFull = links[5];

    navFixture.detectChanges();
    expect(profileLinkFull.navigatedTo)
        .toBeNull('link should not have navigated yet');
    profileLinkDe.triggerEventHandler('click', { button: 0 });
    landingPageLinkDe.triggerEventHandler('click', { button: 0 });
    aboutLinkDe.triggerEventHandler('click', { button: 0 …
Run Code Online (Sandbox Code Playgroud)

angular2-routing angular2-testing angular

14
推荐指数
2
解决办法
1万
查看次数

已请求但未找到标识符为 Xcode.IDEKit.ExtensionSentinelHostApplications 的扩展点

我认为我的 flutter 正在从我拥有 xcode-beta 时开始在错误的路径中寻找某些 xcode 资源。

请注意,此处显示 Xcode-beta.app:

无法在 URL file:///Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/DeviceTypes/iPhone%20SE%20(3rd%20 Generation) 中找到捆绑包).simdevicetype

我在哪里更新这个路径?

完整错误:

    2022-06-18 23:24:33.191 xcodebuild[87140:10387974] Requested but did not find extension point with identifier
    Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of
    plug-in com.apple.dt.IDEWatchSupportCore
    2022-06-18 23:24:33.191 xcodebuild[87140:10387974] Requested but did not find extension point with identifier
    Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension
    Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
    2022-06-18 23:24:33.369 xcodebuild[87140:10387987] Unable to locate a bundle at URL
    file:///Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profi
    les/DeviceTypes/iPhone%20SE%20(3rd%20generation).simdevicetype/
    2022-06-18 23:24:33.369 xcodebuild[87140:10387987] Unable to locate a bundle at URL
    file:///Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profi
    les/Runtimes/iOS.simruntime/
    xcodebuild: error: …
Run Code Online (Sandbox Code Playgroud)

xcode ios flutter

12
推荐指数
2
解决办法
2万
查看次数

Angular 2自定义验证器,它依赖于另一个表单控件

我正在尝试为我的FormControl制作一个自定义验证器 mealType

如果我的FormControl category有值而mealType不是,则mealType应该无效.

如果category没有价值,mealType应该是有效的.

我收到一个控制台错误:

TypeError:无法读取未定义的属性'get'

码:

ngOnInit() {
    this.findForm = this.formBuilder.group({
        categories: [null, Validators.required],
        mealTypes: [null, this.validateMealType],
        distanceNumber: null,
        distanceUnit: 'kilometers',
        keywords: null,
    });
}

validateMealType() {
    if (this.findForm.get('categories').value) {
        if (this.findForm.get('mealTypes').value) {
            var mealTypeError = false;
        } else {
            var mealTypeError = true;
        }
    } else {
        var mealTypeError = false;
    }

    return mealTypeError ? null : {
        error: true
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的形式未定义.

我该如何解决这个问题?

试试这个:

validateMealType(categoryControl: FormControl, mealTypeControl: …
Run Code Online (Sandbox Code Playgroud)

angular2-forms angular

11
推荐指数
3
解决办法
8532
查看次数