创建新的角度4项目时出错

时间:2017-09-12 22:31:19

标签: angular angular-cli

我已成功安装了角度cli,但是当我运行此命令“ng new myApp”时出现错误

“ng未被识别为内部或外部命令” 当我运行这个命令“”

+-- @angular/cli@1.4.1
+-- angular-cli@1.0.0-beta.28.3
+-- babel-core@6.25.0
+-- cordova@6.5.0
+-- ionic@2.2.3
+-- lite-server@2.3.0
+-- live-server@1.2.0
+-- nodemon@1.11.0
+-- npm@5.4.1
`-- udemy-dl@0.0.9

错误在下面给出

npm ERR! peer dep missing: rxjs@^5.0.1, required by @angular/core@2.4.10
npm ERR! missing: q@^1.4.1, required by cordova-common@2.0.0
npm ERR! missing: underscore@^1.8.3, required by cordova-common@2.0.0
npm ERR! missing: base64-js@^1.0.2, required by buffer@4.9.1
npm ERR! missing: isarray@^1.0.0, required by buffer@4.9.1
npm ERR! missing: acorn@^4.0.3, required by syntax-error@1.3.0
npm ERR! missing: punycode@1.3.2, required by url@0.11.0
npm ERR! missing: inherits@2.0.1, required by util@0.10.3
npm ERR! missing: debug@2.6.4, required by finalhandler@1.0.2
npm ERR! missing: debug@2.6.1, required by send@0.15.1
npm ERR! missing: ms@0.7.2, required by send@0.15.1
npm ERR! missing: glob@^7.1.1, required by init-package-json@1.10.1
npm ERR! missing: glob@^7.1.1, required by read-package-json@2.0.5
npm ERR! missing: abbrev@~1.0.9, required by npm@2.15.12
npm ERR! missing: ansicolors@~0.3.2, required by npm@2.15.12
npm ERR! missing: ansistyles@~0.1.3, required by npm@2.15.12
npm ERR! missing: archy@~1.0.0, required by npm@2.15.12
npm ERR! missing: async-some@~1.0.2, required by npm@2.15.12
npm ERR! missing: char-spinner@~1.0.1, required by npm@2.15.12
npm ERR! missing: chmodr@~1.0.2, required by npm@2.15.12
npm ERR! missing: chownr@~1.0.1, required by npm@2.15.12
npm ERR! missing: cmd-shim@~2.0.2, required by npm@2.15.12
npm ERR! missing: columnify@~1.5.4, required by npm@2.15.12
npm ERR! missing: config-chain@~1.1.10, required by npm@2.15.12
npm ERR! missing: dezalgo@~1.0.3, required by npm@2.15.12
npm ERR! missing: editor@~1.0.0, required by npm@2.15.12
npm ERR! missing: fs-vacuum@~1.2.9, required by npm@2.15.12
npm ERR! missing: fs-write-stream-atomic@~1.0.8, required by npm@2.15.12
npm ERR! missing: fstream-npm@~1.1.1, required by npm@2.15.12
npm ERR! missing: github-url-from-git@~1.4.0, required by npm@2.15.12
npm ERR! missing: github-url-from-username-repo@~1.0.2, required by npm@2.15.12
npm ERR! missing: glob@~7.0.6, required by npm@2.15.12
npm ERR! missing: hosted-git-info@~2.1.5, required by npm@2.15.12
npm ERR! missing: init-package-json@~1.9.4, required by npm@2.15.12
npm ERR! missing: lockfile@~1.0.1, required by npm@2.15.12
npm ERR! missing: lru-cache@~4.0.1, required by npm@2.15.12
npm ERR! missing: node-gyp@~3.6.0, required by npm@2.15.12
npm ERR! missing: nopt@~3.0.6, required by npm@2.15.12
npm ERR! missing: normalize-git-url@~3.0.2, required by npm@2.15.12
npm ERR! missing: npm-cache-filename@~1.0.2, required by npm@2.15.12
npm ERR! missing: npm-install-checks@~1.0.7, required by npm@2.15.12
npm ERR! missing: npm-package-arg@~4.1.0, required by npm@2.15.12
npm ERR! missing: npm-registry-client@~7.2.1, required by npm@2.15.12
npm ERR! missing: npm-user-validate@~0.1.5, required by npm@2.15.12
npm ERR! missing: npmlog@~2.0.4, required by npm@2.15.12
npm ERR! missing: path-is-inside@~1.0.0, required by npm@2.15.12
npm ERR! missing: read-installed@~4.0.3, required by npm@2.15.12
npm ERR! missing: readable-stream@~2.1.5, required by npm@2.15.12

我该如何解决?可能是什么问题?

2 个答案:

答案 0 :(得分:1)

我认为问题始于节点安装。 请使用

检查节点版本
node -v
npm -v

节点的最新版本必须为v8.5.0,npm必须是最新版本5.4.1

然后请使用

重新安装角度cli
npm install -g @angular/cli

然后检查版本

ng -v

版本将是1.4.1,如果一切正常,您可以将项目创建为

ng new myNewProject 

答案 1 :(得分:0)

您应该在订单中全局安装Angular Client以直接调用ng命令,请运行:

npm install -g @angular/cli