Jakob Lithner Jakob Lithner - 11 months ago 89
Node.js Question

node_modules issues with angular_cli

I am new to nodejs and npm.

I have installed nodejs 6.9.1 on Windows 10. The corresponding npm version is 3.10.8.

When i run npm install in application directories it usually works fine resulting in local node_modules directory.

But today when I tried the angular-cli everything crashed bigtime ...
I don't know what the reason is, maybe it is not even supported on Windows?

But at the same time I detected that I have a confusing set of node_modules all over the place with different number of modules installed:

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]

The dates indicate they are all updated fairly recently.
Is this normal or should I merge them into the same place to avoid confusion?
System environment variable PATH includes "C:\Program Files\nodejs\" and personal environment variable PATH includes "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

The npm-debug.log file is 1500 kb. All warn and error lines are included in the above dump.

Answer Source

The npm stores packages in many node_modules directories - don't touch them.

In case of angular-cli, you need to install the package in two ways - globally (with -g option) and locally inside the project/app.

Basically: npm install -g angular-cli and then inside your project npm install.

If you already have a (broken) installation of angular-cli, then follow the steps in the official guide.