Angular ng ng new Service:“需要加载工作区,因为它已被使用”

时间:2019-06-28 10:38:25

标签: javascript angular typescript

我想将pusher.js添加到我的angular.json文件中。 但是当我这样做并想创建新服务时,会显示以下错误: 错误:使用工作区之前需要先加载它。 现在有人解决了吗?

我尝试更新角度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"
    ]
}

1 个答案:

答案 0 :(得分:0)

我相信您是错误的目标路径,因为angular.json位于同一级别的node_modules文件夹中。因此,您需要检查angular.json中的node_modules文件夹路径是否正确。

以下是我注意到的问题

{
    "$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 ./
    ]
}

存在相关问题herehere,因此您可以检查一下