error with npm install - Failed at the meanjs@0.3.

2019-08-19 04:14发布

问题:

I am using meanjs as boiler plate code for my project based on mongodb, nodejs, angularjs. I cloned my project in remote server and facing following error during installation

npm ERR! meanjs@0.3.3 postinstall: `bower install --config.interactive=false`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the meanjs@0.3.3 postinstall script.
npm ERR! This is most likely a problem with the meanjs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     bower install --config.interactive=false
npm ERR! You can get their info via:
npm ERR!     npm owner ls meanjs
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.13.0-36-generic
npm ERR! command "node" "/usr/bin/npm" "install"
npm ERR! cwd /home/ubuntu/xyz/xyz
npm ERR! node -v v0.10.35
npm ERR! npm -v 1.3.26
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/ubuntu/xyz/xyz/npm-debug.log
npm ERR! not ok code 0

When I open the debug log following are the errors present. Meanjs supports Node version 0.10.x, npm version 1.3.x. My nodejs and npm versions are v0.10.35 and 1.3.26.

102 info install meanjs@0.3.3
103 info postinstall meanjs@0.3.3
104 verbose unsafe-perm in lifecycle true
105 info meanjs@0.3.3 Failed to exec postinstall script
106 error meanjs@0.3.3 postinstall: `bower install --config.interactive=false`
106 error Exit status 1
107 error Failed at the meanjs@0.3.3 postinstall script.
107 error This is most likely a problem with the meanjs package,
107 error not with npm itself.
107 error Tell the author that this fails on your system:
107 error     bower install --config.interactive=false
107 error You can get their info via:
107 error     npm owner ls meanjs
107 error There is likely additional logging output above.
108 error System Linux 3.13.0-36-generic
109 error command "node" "/usr/bin/npm" "install"
110 error cwd /home/ubuntu/xyz/xyz
111 error node -v v0.10.35
112 error npm -v 1.3.26
113 error code ELIFECYCLE
114 verbose exit [ 1, true ]

回答1:

The postinstall command may be failing because bower is not installed as a global package (which will put the bower command into your PATH.) Try doing this to fix it:

npm install -g bower

Also, you should update npm to the latest version, as 1.3.26 is quite old and no longer supported:

npm install -g npm@latest



回答2:

You might have dependencies conflict, if so use resolutions in the Bower.json.

example:

{
 "name": "test",
 "version": "0.0.1",
 "description": "test",
 "dependencies": {
     "bootstrap": "~3.3.2",
     "angular": "~1.3.12",
     "angular-resource": "~1.3.12"
  },
 "devDependencies": {
      "angular-mocks": "~1.3.12",
      "angular-ui-utils": "~0.2.1"
  },
 "resolutions": {
      "angular": "~1.3.12"
 }
}

If that did not work then it might be the /app/.cache/bower/ used for cache, its common and shared by multiple users.Create a temp folder and point to it in the .bowerrc.

example:

{
  "directory": "public/lib",
  "storage":{ "packages":"temp" }
}

Don't forget to put temp on .gitignore list so not to deploy the folders created locally.

example:

temp/*