У меня проблемы с развертыванием приложения, в котором используется слегка измененная версия модуля publi c NPM, размещенного на Github. Я разветвил репозиторий, внес изменения, зафиксировал их и успешно установил. Модуль работает локально как при разработке, так и при запуске производственной сборки.
Проблема заключается в том, что я развертываю приложение в Elasti c Beanstalk, используя eb deploy <environment name>
. Я знаю, что проблема с этим модулем, потому что я могу успешно развернуть его, если удаляю его из 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 mkdirp@0.5.4: 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 urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm ERR! prepareGitDep 1>
npm ERR! prepareGitDep > deasync@0.1.15 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 > pre-commit@1.2.2 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: fsevents@1.2.9 (node_modules/fsevents):
npm ERR! prepareGitDep npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: 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! pre-commit@1.2.2 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 pre-commit@1.2.2 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 выполняет npm install
как пользователь root.