Tiago
Tiago

Reputation: 43

Error installing fork of public npm module on Elastic Beanstalk

I'm having trouble deploying an application which uses a slightly modified version of a public NPM module which is hosted on Github. I forked the repo and made my changes then committed them and installed it successfully. The module works locally in both development and when running the production build.

The issue is when I deploy the app to Elastic Beanstalk using eb deploy <environment name>. I know that the issue is with this module because I can successfully deploy if I remove it from package.json.

See the error logs below:

  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)

It's worth mentioning that I have previously created a .npmrc file with unsafe-perm=true so EB is running npm install as a root user.

Upvotes: 0

Views: 245

Answers (1)

Tiago
Tiago

Reputation: 43

For anyone stumbling across this problem too, I managed to resolve this by directly copying the built files from the module into my own project and installing any necessary dependencies in package.json.

Upvotes: 1

Related Questions