Getting “npm ERR! code ELIFECYCLE npm ERR! errno 126” while running npm install

泪湿孤枕 提交于 2020-03-05 03:32:30

问题


I am trying to run npm install on my server and getting this error.

> node-cron@2.0.3 postinstall /home/workspace/AgreementCancellationProd/retrymechanism/node_modules/node-cron
> opencollective-postinstall

/usr/bin/env: node: Permission denied
npm WARN retrymechanism@1.0.0 No description
npm WARN retrymechanism@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! node-cron@2.0.3 postinstall: `opencollective-postinstall`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the node-cron@2.0.3 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-03-06T11_22_15_832Z-debug.log

NPM install is running fine on my local system but fails on server.

Also, when I try to install node-cron@2.0.3 using npm install node-cron@2.0.3, it throws the same error.

I am using Amazon Linux on EC2.

I've tried cleaning cache, deleting node_modules & package-lock.json and installing again. Nothing worked.

This is my package.json :

{
  "name": "retrymechanism",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.16.4",
    "fs": "0.0.1-security",
    "mysql2": "^1.6.5",
    "node-cron": "^2.0.3",
    "request": "^2.88.0",
    "sequelize": "^4.42.0"
  }
}

What could be the problem? Please help!


回答1:


I ran into the same problem I used yarn to solve the issue I think it's related to the npm version :

yarn add node-cron@2.0.3



回答2:


Try to remove the "node-cron" from your package-json for a moment and then run npm install. If it works this way, there is a problem with node-cron and you might need to define a different version.




回答3:


That error means one of your js files needs to be marked as executable. Try:

chmod +x src/index.js


来源:https://stackoverflow.com/questions/55022219/getting-npm-err-code-elifecycle-npm-err-errno-126-while-running-npm-install

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!