node_modules 关于 angular_cli 的问题

node_modules issues with angular_cli

我是 nodejs 和 npm 的新手。

我在Windows10上安装了nodejs 6.9.1,对应的npm版本是3.10.8。

当我 运行 npm install 在应用程序目录中时,它通常工作正常,导致本地 node_modules 目录。

但是今天当我尝试 angular-cli 时,一切都崩溃了…… 我不知道是什么原因,也许 Windows 上什至不支持?

但与此同时,我发现我到处都有一组令人困惑的 node_modules,安装了不同数量的模块:

C:\Program Files\nodejs\node_modules [1]
C:\Program Files\nodejs\node_modules\npm\node_modules [82]
C:\Users\Jakob\AppData\Roaming\npm\node_modules [5]
C:\Users\Jakob\AppData\Roaming\npm-cache [1332]

日期表明它们都是最近更新的。 这是正常的还是我应该将它们合并到同一个地方以避免混淆? 系统环境变量PATH包括"C:\Program Files\nodejs\"和个人环境变量PATH包括"C:\Users\Jakob\AppData\Roaming\npm"

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\angular-cli\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.14: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "angular-cli"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! path C:\Users\Jakob\AppData\Roaming\npm\node_modules\.staging\abbrev-51e19594
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename

npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\Jakob\AppData\Roaming\npm\node_modules\.staging\abbrev-51e19594' -> 'C:\Users\Jakob\AppData\Roaming\npm\node_modules\angular-cli\node_modules\npm\node_modules\abbrev'
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\Jakob\AppData\Roaming\npm\node_modules\.staging\abbrev-51e19594' -> 'C:\Users\Jakob\AppData\Roaming\npm\node_modules\angular-cli\node_modules\npm\node_modules\abbrev'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Jakob\Documents\LabSource\a2cli\npm-debug.log
npm ERR! code 1

npm-debug.log 文件是 1500 kb。所有警告和错误行都包含在上面的转储中。

npm 将包存储在许多 node_modules 目录中 - 不要触摸它们。

angular-cli 的情况下,您需要通过两种方式安装包 - globally(使用 -g 选项)和 本地里面project/app。

基本上:npm install -g angular-cli 然后在您的项目中 npm install

如果您已经安装了(损坏的)angular-cli,请按照 the official guide 中的步骤操作。