javascript - 类型错误 : Cannot read property 'config' of null at Class. 运行〜/node_modules/angular-cli/tasks/serve.js:22:61

标签 javascript node.js angular npm

我的产品盒上不断出现此错误,我所做的所有搜索都表明此错误是由于缺少 angular.json 文件引起的,但我没有在项目的根目录中缺少该文件!!!

当我运行 npm start、npm build、npm test 等时,我得到了同样的错误。

当我将存储库克隆到我的产品盒上时,我进入了该文件夹,然后执行了“npm install”,它应该已经安装了所有依赖项,但我无法让这个错误在我的产品盒上消失,而且我不确定产品与开发服务器之间有什么不同会导致此错误。

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

最佳答案

不知何故,这被添加到我的 package.json 文件中:

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

我的 friend 认为脚本可能无意中执行了此操作,但这就是导致错误的原因。

关于javascript - 类型错误 : Cannot read property 'config' of null at Class. 运行〜/node_modules/angular-cli/tasks/serve.js:22:61,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54772256/

相关文章:

javascript - 而 x for at javascript

javascript - 在 ES6 中处理 undefined variable 或属性

angular - 如何在 Angular Material 自动完成中过滤对象

javascript - 如何优化多个文件的输出 typescript 中的模块 namespace ,使用 gulp

javascript - Angular:在每一行上拆分 json 数据

javascript - 如何通过函数获取某个对象的键?

javascript - Angular 中带有子组件的 react 形式

javascript - 是否可以将开放的 Inventor 场景图转换为 Threejs 场景?

javascript - 如何使用 2 个独立的数据库,一个用于写入端,一个用于读取端。 (两个数据库通过eventbus同步)

node.js - 通过 mongoose 流导出到 node-csv