npm install出错 - 在postjs@0.3.3 postinstall脚本失败

时间:2014-12-29 09:38:54

标签: node.js mongodb npm

我使用meanjs作为基于mongodb,nodejs,angularjs的项目的样板代码。我在远程服务器中克隆了我的项目,并在安装过程中面临以下错误

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

当我打开调试日志时,会出现错误。 Meanjs支持节点版本0.10.x,npm版本1.3.x.我的nodejs和npm版本是v0.10.35和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 ]

2 个答案:

答案 0 :(得分:0)

postinstall命令可能失败,因为bower未安装为全局程序包(将bower命令放入PATH。)尝试执行此操作以修复它:

npm install -g bower

另外,您应该将npm更新为最新版本,因为1.3.26已经过时且不再受支持了:

npm install -g npm@latest

答案 1 :(得分:0)

您可能存在依赖项冲突,如果是,请在 Bower.json 中使用resolutions

示例:

{
 "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"
 }
}

如果这不起作用,则可能是/app/.cache/bower/用于缓存,它是常用的并由多个用户共享。创建一个临时文件夹并指向 .bowerrc

示例:

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

不要忘记将temp放在 .gitignore 列表上,以免部署在本地创建的文件夹。

示例:

temp/*