Angular-cli ng不起作用

时间:2017-03-04 07:24:01

标签: angular angular-cli

使用ng serve或npm start命令时显示错误,ng new正在工作。以前它正在工作但现在不行,我已经正确安装了nodejs和angular-cli。提前谢谢。 显示的错误是:

Cannot read property 'glob' of null
TypeError: Cannot read property 'glob' of null
    at ObjectSchemaTreeNode._set (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:224:131)
    at new ObjectSchemaTreeNode (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:209:14)
    at OneOfSchemaTreeNode._createChildProperty (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:148:26)
    at OneOfSchemaTreeNode._typesPrototype.schema.oneOf.map (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:161:25)
    at Array.map (native)
    at OneOfSchemaTreeNode (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:160:48)
    at ArraySchemaTreeNode._createChildProperty (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:148:26)
    at ArraySchemaTreeNode._set (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:286:39)
    at new ArraySchemaTreeNode (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:267:14)
    at ObjectSchemaTreeNode._createChildProperty (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:148:26)
    at ObjectSchemaTreeNode._set (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:224:45)
    at new ObjectSchemaTreeNode (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:209:14)
    at ArraySchemaTreeNode._createChildProperty (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:148:26)
    at ArraySchemaTreeNode._set (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:286:39)
    at new ArraySchemaTreeNode (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:267:14)
    at RootSchemaTreeNode._createChildProperty (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:148:26)
    at RootSchemaTreeNode._set (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:224:45)
    at RootSchemaTreeNode.ObjectSchemaTreeNode (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:209:14)
    at RootSchemaTreeNode (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-tree.js:307:9)
    at GeneratedSchemaClass.SchemaClassBase (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-class-factory.js:53:29)
    at GeneratedSchemaClass (F:\projects\app1\node_modules\@ngtools\json-schema\src\schema-class-factory.js:144:13)
    at new CliConfig (F:\projects\app1\node_modules\@angular\cli\models\config\config.js:18:24)
    at Function.fromConfigPath (F:\projects\app1\node_modules\@angular\cli\models\config\config.js:81:16)
    at Function.fromProject (F:\projects\app1\node_modules\@angular\cli\models\config.js:90:46)
    at Object.<anonymous> (F:\projects\app1\node_modules\@angular\cli\commands\build.js:7:35)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Class.includedCommands (F:\projects\app1\node_modules\@angular\cli\addon\index.js:15:16)
    at F:\projects\app1\node_modules\@angular\cli\ember-cli\lib\models\project.js:287:61
    at Array.forEach (native)
    at Project.addonCommands (F:\projects\app1\node_modules\@angular\cli\ember-cli\lib\models\project.js:286:15)
    at Project.eachAddonCommand (F:\projects\app1\node_modules\@angular\cli\ember-cli\lib\models\project.js:321:30)
    at module.exports (F:\projects\app1\node_modules\@angular\cli\ember-cli\lib\cli\lookup-command.js:33:13)
    at CLI.<anonymous> (F:\projects\app1\node_modules\@angular\cli\ember-cli\lib\cli\cli.js:46:26)
    at tryCatch (F:\projects\app1\node_modules\rsvp\dist\rsvp.js:538:12)
    at invokeCallback (F:\projects\app1\node_modules\rsvp\dist\rsvp.js:553:13)
    at publish (F:\projects\app1\node_modules\rsvp\dist\rsvp.js:521:7)
    at flush (F:\projects\app1\node_modules\rsvp\dist\rsvp.js:2373:5)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

4 个答案:

答案 0 :(得分:1)

听起来像缺少依赖项。尝试删除node_modules并再次运行npm install

答案 1 :(得分:1)

我遇到了同样的问题,我错误地在系统根目录中运行了单元。一旦我删除了所有的angular-cli文件就可以了

我在windows-10系统上做了什么来解决。

  1. 打开cmd。
  2. 运行目录。 (在Linux或Mac中它的ls)。
  3. 如果您发现 angular-cli 文件,只需删除。
  4. 它对我有用。

答案 2 :(得分:0)

这适用于1.3.1。我还将包中的dev从angular/cli 131更改为angular cli 1.7.4(可能是可选的)

验证您是否拥有该目录(ubuntu上为chown groupe:user directory)并尝试为ng(sudo)启动根目录

或/并删除节点目录和-lock.json,运行npm i并启动或sudo launch ng

答案 3 :(得分:0)

我现在知道你需要拥有该目录的权利,以免出现sudo和安装权限问题。你不会需要sudo。再看看npm update。

chown user:user / directory - &gt; 4 ubuntu