Drongo Drongo -4 years ago 113
Javascript Question

Node JS NPM Error

I've installed Node JS on my laptop to learn it locally. It's windows 7 64bit.

I ran the installer which was all fine. However, whenever I try and do anything with npm I get the following error.

Has anyone else experienced this error? I've tried uninstalling and reinstalling to no avail.

Looking at the error it seems to be looking for something on the path Object. (C:\Users\CHANGED_FOR_PRIVACY\AppData\Roaming\npm\node_modules\

But there is nothing actually in that directory/path so do i need to alter a path somewhere? Also, I changed the name of the directory for privacy in this example.

Drongo

$ npm --version
module.js:327
throw err;
^

Error: Cannot find module 'strip-ansi'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (C:\Users\CHANGED_FOR_PRIVACY\AppData\Roaming\npm\node_modules\npm\node_modules\npmlog\node_modules\gauge\node_modules\string-width\index.js:2:17)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)

Answer Source

When I've run into issues like this on Windows with NPM I just fresh install NPM. You can use Cygwin and cURL to install NPM without the node installer.

Download Cygwin

Launch Cygwin Terminal as Administrator, then run the following command

curl -L "https://npmjs.org/install.sh" | sh

This will do a fresh install of NPM. It could take a while to download but once the install completed if everything was successful, the last thing printed will be It Worked.

That should correct your issue.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download