TypeError: 无法在 Class.run ~/node_modules/angular-cli/tasks/serve.js:22:61 读取 null 的属性"config"



我一直在我的产品框上遇到此错误,而我完成的所有搜索都表明此错误是由于缺少angular.json文件引起的,但是我并不丢失该文件我的项目的根!

当我运行NPM启动时,NPM构建,NPM测试等时,我会恢复同样的确切错误。

当我将存储库克隆到我的产品盒上时,我进入了文件夹,然后进行了" NPM安装",该npm安装应该已经安装了所有依赖项,但是我无法在我的产品盒上删除此错误,我不确定什么从prod到开发服务器的不同之处。

dtadmin@my-prod-server:~/portal$ npm test
> ng-crud-table@0.0.0 test /home/portal
> ng test
As a forewarning, we are moving the CLI npm package to "@angular/cli" with the next release,
which will only support Node 6.9 and greater. This package will be officially deprecated
shortly after.
To disable this warning use "ng set --global warnings.packageDeprecation=false".
Cannot read property 'config' of null
TypeError: Cannot read property 'config' of null
    at /home/portal/node_modules/angular-cli/tasks/test.js:12:77
    at new Promise (<anonymous>)
    at Class.run (/home/portal/node_modules/angular-cli/tasks/test.js:10:16)
    at Class.run (/home/portal/node_modules/angular-cli/commands/test.js:29:25)
    at Class.<anonymous> (/home/portal/node_modules/angular-cli/ember-cli/lib/models/command.js:134:17)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
npm ERR! Test failed.  See above for more details.

这是我的test.js文件:


"use strict";
var Task = require('../ember-cli/lib/models/task');
var path = require('path');
var require_project_module_1 = require('../utilities/require-project-module');
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Task.extend({
    run: function (options) {
        var _this = this;
        var projectRoot = this.project.root;
        return new Promise(function (resolve) {
            var karma = require_project_module_1.requireDependency(projectRoot, 'karma');
            var karmaConfig = path.join(projectRoot, _this.project.ngConfig.config.test.karma.config);
            var karmaOptions = Object.assign({}, options);
            // Convert browsers from a string to an array
            if (options.browsers) {
                karmaOptions.browsers = options.browsers.split(',');
            }
            karmaOptions.angularCli = {
                codeCoverage: options.codeCoverage,
                sourcemap: options.sourcemap,
                progress: options.progress
            };
            // Assign additional karmaConfig options to the local ngapp config
            karmaOptions.configFile = karmaConfig;
            // :shipit:
            var karmaServer = new karma.Server(karmaOptions, resolve);
            karmaServer.start();
        });
    }
});
//# sourceMappingURL=/Users/hans/Sources/angular-cli/packages/angular-cli/tasks/test.js.map

以某种方式将其添加到我的软件包中。

"angular-cli": "^1.0.0-beta.28.3",

我的朋友认为脚本可能会无意间做到这一点,但这就是导致错误的原因。

最新更新