2

I'm new to node.js. I'm using WebStorm. I work on Windows.

I configured my app to run on node.js and when I try to run it I get this error:"Cannot find module 'merge-descriptors'".

I followed these post trying to solve it: How do I resolve "Cannot find module" error using Node.js?, module.js:338 throw err in node.js

I ran "del /s /q node_modules" (parallel to "rm -rf node_modules"). Now I'm trying to run "npm install -g" and I'm getting this error:

See screen shot below enter image description here

I've tried to understand it and to look for information about it in the net to no avail.

Any help will be profoundly appreciated!

Community
  • 1
  • 1
Alon
  • 10,381
  • 23
  • 88
  • 152
  • Please provide your files folder in workspace only names – Rahul Kamboj Dec 30 '15 at 04:24
  • The error occurs in the file express.js in line 16: var mixin = require('merge-descriptors'); – Alon Dec 30 '15 at 04:31
  • @alon do not run `npm install -g`. If you are trying to install a project from a package.json file you should only be running `npm install` in the root where the package file is. – travis Dec 30 '15 at 06:25
  • Thanks @travis it solved the problem! Please write it again as an answer and I'll mark it as the correct answer. – Alon Dec 30 '15 at 23:09

3 Answers3

7

I had similar issue installing the module, I tried npm install or npm update but my network would timeout. However what I did is very simple:

npm install merge-descriptors --save
Bamanyi
  • 83
  • 1
  • 4
2

When installing the dependencies for a package you should be using npm install and not using the -g flag.

The g flag, or global is used when installing a package globally, which places them in a direct location that is not accessible by the project.

See https://docs.npmjs.com/files/folders

travis
  • 8,055
  • 1
  • 17
  • 19
0

The specific error you're seeing is that the logged in user doesn't have permission to write to the install directory. This can be overcome with sudo command, ex., sudo npm install. But as others have indicated, if you have to do this then something about your app's configuration could be wrong.

Kevin Curry
  • 117
  • 1
  • 5