小编Pra*_*eep的帖子

错误:找不到本地工作区文件('angular.json')

我已经travis-ci与我的GitHub帐户集成(https://github.com/pradeep0601/Angular5-Router-App).

当我将@angular/cli版本从1.7.4 更新到6.0.0-rc.3时,构建开始失败并出现错误:

Local workspace file ('angular.json') could not be found.
Error: Local workspace file ('angular.json') could not be found.
    at WorkspaceLoader._getProjectWorkspaceFilePath (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/workspace-loader.js:37:19)
    at WorkspaceLoader.loadWorkspace (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/workspace-loader.js:24:21)
    at TestCommand._loadWorkspaceAndArchitect (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:177:32)
    at TestCommand.<anonymous> (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:45:25)
    at Generator.next (<anonymous>)
    at /home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:3:12)
    at TestCommand.initialize (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:44:16)
    at /home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/command-runner.js:100:23
Run Code Online (Sandbox Code Playgroud)

package.json片段以更好地了解运行环境:

    "@angular/cli": "6.0.0-rc.3",
    "@angular/compiler-cli": "^5.2.0",
    "@angular/language-service": "^5.2.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
Run Code Online (Sandbox Code Playgroud)

travis-ci angular-cli package-lock.json

187
推荐指数
8
解决办法
24万
查看次数

firebase phone auth错误:令牌无效.在nativeToJSError

我正在使用firebase phone auth在本机应用程序中使用此文档我在一些不同的设备上测试了它.有时电话验证工作,有时它会抛出此错误

firebase phone auth错误:令牌无效.在nativeToJSError

在此输入图像描述

我是通过firebase的文档做的,并尝试了解这个错误.那是我的代码.

confirmPhone = async (phoneNumber) => {
    const phoneWithAreaCode = phoneNumber.replace(/^0+/, '+972');
    return new Promise((res, rej) => {
        firebase.auth().verifyPhoneNumber(phoneWithAreaCode)
            .on('state_changed', async (phoneAuthSnapshot) => {
                switch (phoneAuthSnapshot.state) {
                    case firebase.auth.PhoneAuthState.AUTO_VERIFIED:
                        UserStore.setVerificationId(phoneAuthSnapshot.verificationId)
                        await this.confirmCode(phoneAuthSnapshot.verificationId, phoneAuthSnapshot.code, phoneAuthSnapshot)
                        res(phoneAuthSnapshot)

                        break

                    case firebase.auth.PhoneAuthState.CODE_SENT:
                        UserStore.setVerificationId(phoneAuthSnapshot.verificationId)
                        res(phoneAuthSnapshot)
                        break

                    case firebase.auth.PhoneAuthState.AUTO_VERIFY_TIMEOUT:
                        UserStore.setVerificationId(phoneAuthSnapshot.verificationId)
                        UserStore.setErrorCodeAuthentication('SMS code has expired')
                        res(phoneAuthSnapshot)


                    case firebase.auth.PhoneAuthState.ERROR:
                        console.log(phoneAuthSnapshot.error.code)
                        if (phoneAuthSnapshot.error) {
                            this.showMessageErrorByCode(phoneAuthSnapshot.error.code)

                        }

                        rej(phoneAuthSnapshot)
                        break

                }
            })
    })
}

confirmCode = async (verificationId, code, phoneAuthSnapshot) => {
    console.log(verificationId,code); …
Run Code Online (Sandbox Code Playgroud)

javascript firebase react-native firebase-authentication

20
推荐指数
1
解决办法
538
查看次数

ES6生成器:来自iterator.throw的错误堆栈跟踪(错误)

ES-6 iterator.throw(err)方法通常被描述为注入异常,就好像它发生在yield生成器中的语句中一样.问题是此异常的堆栈跟踪不包含对yield语句的文件/行的任何引用,甚至不包含它所在的函数.相反,堆栈跟踪似乎只在构造异常对象时生成,哪个不在里面generator.

问题是:如何在堆栈跟踪中获取有问题的yield语句的位置?

function* one_of_many_generators() {
    // ...
    yield ajax(url);    // <-- what I need in the stack trace
    // ...
}

function outer() {
    var iterator = one_of_many_generators();
    iterator.next();    // runs to the first yield

    // inject exception at the yield statement
    iterator.throw(Error("error"));   // <-- top of stack trace shows here
}
Run Code Online (Sandbox Code Playgroud)

虽然这个问题不是特定的Promises,但它们可能更容易描述问题.就我而言,我正在使用具有生成器和承诺的任务系统.假设函数ajax()返回Promise,如果拒绝,则使用此机制将错误转换为yield语句中的throw.

调试器中的堆栈跟踪非常无用,因为我找不到获取yield statement此注入发生位置的函数,文件或行号的方法.调用iterator.throw(err)被视为重新抛出,并且不会获得新的堆栈信息,因此它只显示ajax()函数内部可以从许多地方调用的位置,并且通过outer()像上面的示例中那样抛出新错误,相同的抛出线显示对于所有错误.两者都没有给出generator关于调试错误所执行的函数的提示. …

javascript ajax yield generator ecmascript-6

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

在元素顶部添加一个 DividerItemDecoration

我正在尝试在 RecyclerView 中的元素顶部添加一个分隔符。

跟随谷歌我已经成功添加了一个DividerItemDecoration,代码如下:

分隔项装饰:

public class DividerItemDecoration extends RecyclerView.ItemDecoration {

private static final int[] ATTRS = new int[]{
        android.R.attr.listDivider
};

public static final int HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL;
public static final int VERTICAL_LIST = LinearLayoutManager.VERTICAL;
private Drawable mDivider;
private int mOrientation;

public DividerItemDecoration(Context context, int orientation) {
    final TypedArray a = context.obtainStyledAttributes(ATTRS);
    mDivider = a.getDrawable(0);
    a.recycle();
    setOrientation(orientation);
}

public void setOrientation(int orientation) {
    if (orientation != HORIZONTAL_LIST && orientation != VERTICAL_LIST) {
        throw new IllegalArgumentException("invalid orientation");
    }
    mOrientation = orientation; …
Run Code Online (Sandbox Code Playgroud)

java android android-layout android-recyclerview

6
推荐指数
1
解决办法
1327
查看次数

如果我们可以使ArrayList同步,那么Vector的需求是什么?

如果我们可以使ArrayList同步,那么Vector的需求是什么?同样,如果我们可以使HashMap同步,那么Hashtable的需求是什么?

java

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