在Elastic Beanstalk上安装公共npm模块的fork时出错

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

我在部署使用Github上托管的公共NPM模块的经过稍微修改的版本的应用程序时遇到了麻烦。我分叉了仓库,并进行了更改,然后提交并成功安装。该模块在开发和运行生产版本时均在本地工作。

问题是当我使用eb deploy <environment name>将应用程序部署到Elastic Beanstalk时。我知道问题出在这个模块上,因为如果从package.json中删除它,我可以成功进行部署。

请参见下面的错误日志:

  npm ERR! A complete log of this run can be found in:
  npm ERR!     /tmp/.npm/_logs/2020-04-02T12_28_43_807Z-debug.log
  Running npm install:  /opt/elasticbeanstalk/node-install/node-v12.16.1-linux-x64/bin/npm
  Setting npm config jobs to 1
  npm config jobs set to 1
  Running npm with --production flag
  Failed to run npm install. Snapshot logs for more details.
  UTC 2020/04/02 12:28:50 cannot find application npm debug log at /tmp/deployment/application/npm-debug.log 

  Traceback (most recent call last):
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 695, in <module>
      main()
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 677, in main
      node_version_manager.run_npm_install(options.app_path)
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 136, in run_npm_install
      self.npm_install(bin_path, self.config_manager.get_container_config('app_staging_dir'))
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 180, in npm_install
      raise e
  subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v12.16.1-linux-x64/bin/npm', '--production', 'install']' returned non-zero exit status 1 (ElasticBeanstalk::ExternalInvocationError)
caused by: + /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install
  npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
  npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
  npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
  npm ERR! prepareGitDep 1> 
  npm ERR! prepareGitDep > [email protected] install /tmp/.npm/_cacache/tmp/git-clone-f83c32d6/node_modules/deasync
  npm ERR! prepareGitDep > node ./build.js
  npm ERR! prepareGitDep 
  npm ERR! prepareGitDep `linux-x64-node-12` exists; testing
  npm ERR! prepareGitDep Binary is fine; exiting
  npm ERR! prepareGitDep 
  npm ERR! prepareGitDep > [email protected] install /tmp/.npm/_cacache/tmp/git-clone-f83c32d6/node_modules/pre-commit
  npm ERR! prepareGitDep > node install.js
  npm ERR! prepareGitDep 
  npm ERR! prepareGitDep 
  npm ERR! prepareGitDep 2> npm WARN install Usage of the `--dev` option is deprecated. Use `--only=dev` instead.
  npm ERR! prepareGitDep internal/fs/utils.js:230
  npm ERR! prepareGitDep     throw err;
  npm ERR! prepareGitDep     ^
  npm ERR! prepareGitDep 
  npm ERR! prepareGitDep Error: EACCES: permission denied, mkdir '/tmp/.npm/_cacache/tmp/git-clone-f83c32d6/.git/hooks'
  npm ERR! prepareGitDep     at Object.mkdirSync (fs.js:840:3)
  npm ERR! prepareGitDep     at Object.<anonymous> (/tmp/.npm/_cacache/tmp/git-clone-f83c32d6/node_modules/pre-commit/install.js:28:24)
  npm ERR! prepareGitDep     at Module._compile (internal/modules/cjs/loader.js:1158:30)
  npm ERR! prepareGitDep     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
  npm ERR! prepareGitDep     at Module.load (internal/modules/cjs/loader.js:1002:32)
  npm ERR! prepareGitDep     at Function.Module._load (internal/modules/cjs/loader.js:901:14)
  npm ERR! prepareGitDep     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
  npm ERR! prepareGitDep     at internal/main/run_main_module.js:18:47 {
  npm ERR! prepareGitDep   errno: -13,
  npm ERR! prepareGitDep   syscall: 'mkdir',
  npm ERR! prepareGitDep   code: 'EACCES',
  npm ERR! prepareGitDep   path: '/tmp/.npm/_cacache/tmp/git-clone-f83c32d6/.git/hooks'
  npm ERR! prepareGitDep }
  npm ERR! prepareGitDep npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
  npm ERR! prepareGitDep npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
  npm ERR! prepareGitDep 
  npm ERR! prepareGitDep npm ERR! code ELIFECYCLE
  npm ERR! prepareGitDep npm ERR! errno 1
  npm ERR! prepareGitDep npm ERR! [email protected] install: `node install.js`
  npm ERR! prepareGitDep npm ERR! Exit status 1
  npm ERR! prepareGitDep npm ERR! 
  npm ERR! prepareGitDep npm ERR! Failed at the [email protected] install script.
  npm ERR! prepareGitDep npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  npm ERR! prepareGitDep 
  npm ERR! prepareGitDep npm ERR! A complete log of this run can be found in:
  npm ERR! prepareGitDep npm ERR!     /tmp/.npm/_logs/2020-04-02T12_28_43_507Z-debug.log
  npm ERR! prepareGitDep 
  npm ERR! premature close

  npm ERR! A complete log of this run can be found in:
  npm ERR!     /tmp/.npm/_logs/2020-04-02T12_28_43_807Z-debug.log
  Running npm install:  /opt/elasticbeanstalk/node-install/node-v12.16.1-linux-x64/bin/npm
  Setting npm config jobs to 1
  npm config jobs set to 1
  Running npm with --production flag
  Failed to run npm install. Snapshot logs for more details.
  UTC 2020/04/02 12:28:50 cannot find application npm debug log at /tmp/deployment/application/npm-debug.log 

  Traceback (most recent call last):
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 695, in <module>
      main()
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 677, in main
      node_version_manager.run_npm_install(options.app_path)
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 136, in run_npm_install
      self.npm_install(bin_path, self.config_manager.get_container_config('app_staging_dir'))
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 180, in npm_install
      raise e
  subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v12.16.1-linux-x64/bin/npm', '--production', 'install']' returned non-zero exit status 1 (Executor::NonZeroExitStatus)

值得一提的是,我之前使用.npmrc创建了一个unsafe-perm=true文件,因此EB以root用户身份运行npm install

我在部署使用Github上托管的公共NPM模块的经过稍微修改的版本的应用程序时遇到了麻烦。我分叉了仓库,并进行了更改,然后提交了,然后...

node.js amazon-web-services github npm amazon-elastic-beanstalk
1个回答
0
投票

对于也遇到这个问题的任何人,我都设法解决了这一问题,方法是直接将构建的文件从模块复制到我自己的项目中,并在package.json中安装任何必要的依赖项。

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