Angular on ng 新服务:"需要加载工作区才能使用它"



我想将pusher.js添加到我的angular.json文件中。但是,当我这样做并想创建一项新服务以下以下错误错误:错误:需要在使用工作空间之前加载。现在有人解决这个问题吗?

我试图更新Angular CLI,但没有任何效果...这是我的angular.json文件:

{
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "projects": {
        "iotbrowser": {
            "root": "",
            "sourceRoot": "src/main/webapp",
            "projectType": "application",
            "architect": {}
        }
    },
    "defaultProject": "iotbrowser",
    "cli": {
        "packageManager": "npm"
    },
    "schematics": {
        "@schematics/angular:component": {
            "inlineStyle": true,
            "inlineTemplate": false,
            "spec": false,
            "prefix": "jhi",
            "styleExt": "scss"
        },
        "@schematics/angular:directive": {
            "spec": false,
            "prefix": "jhi"
        },
        "@schematics/angular:guard": {
            "spec": false
        },
        "@schematics/angular:pipe": {
            "spec": false
        },
        "@schematics/angular:service": {
            "spec": false
        }
    },
    "scripts":[
        "../node_modules/pusher-js/dist/web/pusher.min.js"
    ]
}

i相信您是目标路径,因为Angular.json处于相同级别的node_modules文件夹中。因此,您需要检查node_modules文件夹路径在angular.json中正确。

以下是我注意到的问题

{
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "projects": {
        "iotbrowser": {
            "root": "",
            "sourceRoot": "src/main/webapp",
            "projectType": "application",
            "architect": {}
        }
    },
    "defaultProject": "iotbrowser",
    "cli": {
        "packageManager": "npm"
    },
    "schematics": {
        "@schematics/angular:component": {
            "inlineStyle": true,
            "inlineTemplate": false,
            "spec": false,
            "prefix": "jhi",
            "styleExt": "scss"
        },
        "@schematics/angular:directive": {
            "spec": false,
            "prefix": "jhi"
        },
        "@schematics/angular:guard": {
            "spec": false
        },
        "@schematics/angular:pipe": {
            "spec": false
        },
        "@schematics/angular:service": {
            "spec": false
        }
    },
    "scripts":[
        "./node_modules/pusher-js/dist/web/pusher.min.js" // this one change to ./
    ]
}

这里和这里都有相关问题,因此您可以检查

最新更新