【问题标题】:Getting "npm ERR! code ELIFECYCLE npm ERR! errno 126" while running npm install运行 npm install 时获取“npm ERR!code ELIFECYCLE npm ERR!errno 126”
【发布时间】:2019-07-28 01:35:25
【问题描述】:

我正在尝试在我的服务器上运行 npm install 并收到此错误。

> 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 安装在我的本地系统上运行良好,但在服务器上失败。

另外,当我尝试使用npm install node-cron@2.0.3 安装 node-cron@2.0.3 时,它会抛出同样的错误。

我在 EC2 上使用 Amazon Linux

我已经尝试清理缓存,删除 node_modules 和 package-lock.json 并再次安装。没有任何效果。

这是我的 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"
  }
}

可能是什么问题?请帮忙!

【问题讨论】:

    标签: javascript node.js npm-install node-cron amazon-linux-2


    【解决方案1】:

    对于在使用 Jenkins 部署 React JS 应用程序时遇到相同问题的任何人,我即兴创作了 @oabarca's answer above,它成功了。只要确保在npm install 之后和npm run build 之前有这行chmod +x ./node_modules/.bin/react-scripts,如下所示:

    pwd
    npm install
    chmod +x ./node_modules/.bin/react-scripts   # add this line
    npm run build
    # ..rest of the code here
    

    希望它可以节省一些人在谷歌上搜索的时间;)

    【讨论】:

      【解决方案2】:

      该错误意味着您的 js 文件之一需要标记为可执行文件。试试:

      chmod +x src/index.js
      

      【讨论】:

        【解决方案3】:

        我遇到了同样的问题,我使用yarn 解决了我认为与npm 版本有关的问题:

        yarn add node-cron@2.0.3
        

        【讨论】:

        • 我使用“yarn add node-cron@2.0.3”而不是“yarn install node-cron@2.0.3”
        • 太棒了!固定:)
        【解决方案4】:

        尝试从您的 package-json 中删除“node-cron”片刻,然后运行 ​​npm install。 如果它以这种方式工作,则 node-cron 存在问题,您可能需要定义不同的版本。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-01-27
          • 2021-07-29
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-06-28
          相关资源
          最近更新 更多