Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM doesn't install module dependencies

Tags:

npm

This is my package.json for the module that I'm including in the parent project:

{   "version": "0.0.1",   "name": "module-name",   "dependencies": {     "express": "3.3.4",     "grunt": "0.4.1",     "grunt-contrib-compass": "0.4.0",     "grunt-contrib-copy": "0.4.1",     "grunt-contrib-cssmin": "0.4.1",     "grunt-contrib-jshint": "0.6.3",     "grunt-contrib-requirejs": "0.4.1",     "grunt-contrib-uglify": "0.2.2",     "grunt-contrib-watch": "0.5.1",     "grunt-express-server": "0.4.1",     "grunt-karma": "0.4.5",     "grunt-regex-replace": "0.2.5",     "request": "2.25.0"   },   "scripts": {     "postinstall": "grunt install"   } } 

One thing to note is that this module is contained in a private repo and I include it in the parent package.json like: "module-name": "git+ssh://git@myserver:user/module-name.git"

like image 536
Ahmed Nuaman Avatar asked Aug 23 '13 11:08

Ahmed Nuaman


People also ask

Can't install dependencies npm?

The easiest way to fix the issue is to pass an additional parameter –legacy-peer-deps to npm install. The --legacy-peer-deps tells the npm to ignore the peer dependencies and continue the installation of the package. Try the below command to install the dependencies for your project.

Does npm install dependencies of dependencies?

By default, npm install will install all modules listed as dependencies in package.

Why is my npm install not working?

The Npm command not found error can appear when you install or upgrade npm. On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.


2 Answers

It looks like you hit a bug that has existed for quite a while and doesn't have solution yet. There are several open issues for this case in the npm repository:

  • npm install should recursively check/install dependencies https://github.com/npm/npm/issues/1341 (closed)
  • local private module dependencies https://github.com/npm/npm/issues/2442 (closed)

In the first one people list several workarounds that you may try.

An alternative solution may be (a little hackish) to explicitly list the dependencies as first level dependents. This requires you to maintain the list but practically it has to be done very infrequently.

like image 123
allprog Avatar answered Sep 19 '22 15:09

allprog


I had very similar issue, removing entire node_modules folder and re-installing worked for me. Learned this trick from the IT Crowd show!

rm -rf node_modules npm install 
like image 44
Mohsen Avatar answered Sep 18 '22 15:09

Mohsen