Bcrypt Elastic beanstalk nodejs部署

问题描述 投票:4回答:1

我试图将我的nodejs后台用codeship部署到elastic beanstalk上。但每次我都会得到以下错误,有人知道如何解决吗?

[email protected] install /tmp/deployment/application/node_modules/bcrypt
node-pre-gyp install --fallback-to-build

module.js:471
throw err;
^

Error: Cannot find module '../'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/tmp/deployment/application/node_modules/.bin/node-pre-gyp:15:20)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)

npm ERR! Linux 4.9.62-21.56.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v6.11.5-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v6.11.5-linux-x64/bin/npm" "--production" "rebuild"
npm ERR! node v6.11.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs bcrypt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls bcrypt
npm ERR! There is likely additional logging output above.

有谁知道如何解决这个问题? 我已经尝试解决这个问题好几天了,非常感谢大家的帮助

node.js amazon-elastic-beanstalk bcrypt continuous-deployment
1个回答
4
投票

尝试使用 bcrypt.js 模块而不是 bcrypt 这是一个更新最新的npm模块。 运行 npm install bcrypt.js 然后 npm install


3
投票

请看这个GitHub评论。https:/github.comkelektivnode.bcrypt.jsissues509#issuecomment-313693838。

TL;DR:作为一个变通的方法,运行 npm install bcrypt 运转前 npm install


0
投票

我创建了一个 .npmrc 文件与。

unsafe-perm=true

似乎已经完成了。


0
投票

添加 bcryptjs 在您的 package.json 然后 npm install 应该可以和所有的依赖关系一起工作。


0
投票

首先确保你没有上传node模块文件夹,并且npm安装命令在实例上工作。

https:/github.comkelektivnode.bcrypt.jswikiInstallation-Instructions。

这个问题与node-pre-gyp有关。bcrypt的一个依赖关系。

对于AWS Elastic Beanstalk,当部署到运行Node 8.x的Elastic Beanstalk时,node-gyp没有足够的权限写入tmp目录,bcrypt将无法安装,应用部署将失败。

一个变通的办法是在项目的根目录下添加一个.npmrc文件,强制node-gyp以root身份运行并允许安装完成。.npmrc的文件内容。

# Force npm to run node-gyp also as root, preventing permission denied errors in AWS with npm@5 or @6
unsafe-perm=true

另一种方法(也许是更正确的方法)是用代码制作.ebextensions文件。

.ebextensions:00_change_npm_permissions.config。

  "/opt/elasticbeanstalk/hooks/appdeploy/post/00_set_tmp_permissions.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      chown -R nodejs:nodejs /tmp/.npm

这将使你有足够的权限来运行node-gyp。

© www.soinside.com 2019 - 2024. All rights reserved.