无法安装 sqlite3 作为对 AWS 的依赖项
Posted
技术标签:
【中文标题】无法安装 sqlite3 作为对 AWS 的依赖项【英文标题】:Unable to install sqlite3 as a dependency on AWS 【发布时间】:2021-01-02 13:36:36 【问题描述】:我创建了一个使用 SQLite 存储数据的应用程序。在本地运行良好,我尝试在AWS上部署node应用,但是无法安装SQLite3
包,不知道为什么。
eb-engine
LOG
----------------------------------------
/var/log/eb-engine.log
----------------------------------------
2020/09/15 18:27:56.475030 [INFO] Downloading: bucket: elasticbeanstalk-eu-west-1-517303674880, object: /resources/environments/e-fdemiazfan/_runtime/versions/manifest_1600194473607
2020/09/15 18:27:56.537203 [INFO] Download successful158bytes downloaded
2020/09/15 18:27:56.537358 [INFO] Trying to read and parse version manifest...
2020/09/15 18:27:56.537432 [INFO] Downloading: bucket: elasticbeanstalk-eu-west-1-517303674880, object: /resources/environments/e-fdemiazfan/_runtime/_versions/llaimagames-backend/code-pipeline-1600194468852-6f5ca48cf59015e5287229cc2aa09408bb1cf111
2020/09/15 18:27:56.547941 [INFO] Download successful10287bytes downloaded
2020/09/15 18:27:56.548121 [INFO] Executing instruction: ElectLeader
2020/09/15 18:27:56.548135 [INFO] Running leader election for instance i-0fbd2ec436aa6952a...
2020/09/15 18:27:56.548139 [INFO] Calling the cfn-elect-cmd-leader to elect the command leader.
2020/09/15 18:27:56.548155 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-elect-cmd-leader --stack arn:aws:cloudformation:eu-west-1:517303674880:stack/awseb-e-fdemiazfan-stack/fd62a1f0-f68e-11ea-bd15-0a9bdcf5c20a --command-name ElasticBeanstalkCommand-AWSEBAutoScalingGroup --invocation-id ef591c3d-43c6-4082-aabe-2aeacff9aec6 --listener-id i-0fbd2ec436aa6952a --region eu-west-1
2020/09/15 18:27:56.894802 [INFO] Instance is Leader.
2020/09/15 18:27:56.894847 [INFO] Executing instruction: stopSqsd
2020/09/15 18:27:56.894852 [INFO] This is a web server environment instance, skip stop sqsd daemon ...
2020/09/15 18:27:56.894857 [INFO] Executing instruction: PreBuildEbExtension
2020/09/15 18:27:56.894876 [INFO] Starting executing the config set Infra-EmbeddedPreBuild.
2020/09/15 18:27:56.894899 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-init -s arn:aws:cloudformation:eu-west-1:517303674880:stack/awseb-e-fdemiazfan-stack/fd62a1f0-f68e-11ea-bd15-0a9bdcf5c20a -r AWSEBAutoScalingGroup --region eu-west-1 --configsets Infra-EmbeddedPreBuild
2020/09/15 18:27:57.259401 [INFO] Finished executing the config set Infra-EmbeddedPreBuild.
2020/09/15 18:27:57.259424 [INFO] Executing instruction: StageApplication
2020/09/15 18:27:57.259825 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
2020/09/15 18:27:57.259850 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
2020/09/15 18:27:57.262669 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ successfully
2020/09/15 18:27:57.263178 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2020/09/15 18:27:57.263196 [INFO] The dir .platform/hooks/prebuild/ does not exist in the application. Skipping this step...
2020/09/15 18:27:57.263201 [INFO] Executing instruction: Install customer specified node.js version
2020/09/15 18:27:57.263205 [INFO] installing specified nodejs version...
2020/09/15 18:27:57.263272 [INFO] there is no nodejs version specified in package.json, skip installing specified version of nodejs
2020/09/15 18:27:57.263281 [INFO] Executing instruction: Use NPM to install dependencies
2020/09/15 18:27:57.263291 [INFO] use npm to install dependencies
2020/09/15 18:27:57.263320 [INFO] Running command /bin/sh -c npm config set jobs 1
2020/09/15 18:27:57.496763 [INFO] Running command /bin/sh -c npm --production install
2020/09/15 18:28:03.895258 [INFO]
> sqlite3@5.0.0 install /var/app/staging/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build
Failed to execute '/opt/elasticbeanstalk/node-install/node-v12.18.3-linux-x64/bin/node /opt/elasticbeanstalk/node-install/node-v12.18.3-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/var/app/staging/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/var/app/staging/node_modules/sqlite3/lib/binding/napi-v3-linux-x64 --napi_version=6 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
2020/09/15 18:28:03.895293 [ERROR] An error occurred during execution of command [app-deploy] - [Use NPM to install dependencies]. Stop running the command. Error: Command /bin/sh -c npm --production install failed with error exit status 1. Stderr:npm WARN deprecated crypto@1.0.1: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for sqlite3@5.0.0 and node@12.18.3 (node-v72 ABI, glibc) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/var/app/staging/node_modules/sqlite3/lib/binding'
gyp WARN EACCES current user ("healthd") does not have permission to access the dev dir "/root/.cache/node-gyp/12.18.3"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/var/app/staging/node_modules/sqlite3/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/var/app/staging/node_modules/sqlite3/.node-gyp'
gyp ERR! System Linux 4.14.192-147.314.amzn2.x86_64
gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v12.18.3-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v12.18.3-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/var/app/staging/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/var/app/staging/node_modules/sqlite3/lib/binding/napi-v3-linux-x64" "--napi_version=6" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
gyp ERR! cwd /var/app/staging/node_modules/sqlite3
gyp ERR! node -v v12.18.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/opt/elasticbeanstalk/node-install/node-v12.18.3-linux-x64/bin/node /opt/elasticbeanstalk/node-install/node-v12.18.3-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/var/app/staging/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/var/app/staging/node_modules/sqlite3/lib/binding/napi-v3-linux-x64 --napi_version=6 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/var/app/staging/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:315:20)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Linux 4.14.192-147.314.amzn2.x86_64
node-pre-gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v12.18.3-linux-x64/bin/node" "/var/app/staging/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /var/app/staging/node_modules/sqlite3
node-pre-gyp ERR! node -v v12.18.3
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
npm WARN backend@2.0.0 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sqlite3@5.0.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sqlite3@5.0.0 install 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/2020-09-15T18_28_03_882Z-debug.log
2020/09/15 18:28:03.895312 [INFO] Executing cleanup logic
2020/09/15 18:28:03.895406 [INFO] CommandService Response: "status":"FAILURE","api_version":"1.0","results":["status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":["msg":"Instance deployment: You didn't specify a Node.js version in the 'package.json' file in your source bundle. The deployment didn't install a specific Node.js version.","timestamp":1600194477,"severity":"INFO","msg":"Instance deployment: 'npm' failed to install dependencies that you defined in 'package.json'. For details, see 'eb-engine.log'. The deployment failed.","timestamp":1600194483,"severity":"ERROR","msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1600194483,"severity":"ERROR"]]
2020/09/15 18:28:03.895555 [INFO] Platform Engine finished execution on command: app-deploy
2020/09/15 18:28:50.916583 [INFO] Starting...
2020/09/15 18:28:50.916625 [INFO] Starting EBPlatform-PlatformEngine
2020/09/15 18:28:50.916640 [INFO] reading event message file
2020/09/15 18:28:50.916736 [INFO] no eb envtier info file found, skip loading env tier info.
2020/09/15 18:28:50.916805 [INFO] Engine received EB command cfn-hup-exec
2020/09/15 18:28:50.990909 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:eu-west-1:517303674880:stack/awseb-e-fdemiazfan-stack/fd62a1f0-f68e-11ea-bd15-0a9bdcf5c20a -r AWSEBAutoScalingGroup --region eu-west-1
2020/09/15 18:28:51.300432 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:eu-west-1:517303674880:stack/awseb-e-fdemiazfan-stack/fd62a1f0-f68e-11ea-bd15-0a9bdcf5c20a -r AWSEBBeanstalkMetadata --region eu-west-1
2020/09/15 18:28:51.593864 [INFO] checking whether command tail-log is applicable to this instance...
2020/09/15 18:28:51.593877 [INFO] this command is applicable to the instance, thus instance should execute command
2020/09/15 18:28:51.593881 [INFO] Engine command: (tail-log)
2020/09/15 18:28:51.593928 [INFO] Executing instruction: GetTailLogs
2020/09/15 18:28:51.593933 [INFO] Tail Logs...
2020/09/15 18:28:51.594172 [INFO] Running command /bin/sh -c tail -n 100 /var/log/eb-engine.log
Package.json
"name": "backend",
"version": "2.0.0",
"description": "",
"main": "server.js",
"scripts":
"test": "echo \"Error: no test specified\" && exit 1",
,
"author": "",
"license": "ISC",
"dependencies":
"body-parser": "^1.19.0",
"crypto": "^1.0.1",
"express": "^4.17.1",
"mysql": "^2.18.1",
"sqlite3": "^5.0.0"
【问题讨论】:
SQLLite 是唯一有问题的包吗?如果你删除它,其他一切都会成功吗? @petern 是的 node.js 和 npm 版本相同?如果不是,请尝试将两者匹配。 【参考方案1】:gyp ERR! stack Error: EACCES: permission denied, mkdir '/var/app/staging/node_modules/sqlite3/.node-gyp' gyp ERR! System Linux 4.14.192-147.314.amzn2.x86_64
here 提出的问题可能重复
尝试添加.npmrc
和unsafe-perm=true
【讨论】:
以上是关于无法安装 sqlite3 作为对 AWS 的依赖项的主要内容,如果未能解决你的问题,请参考以下文章
AWS CodeBuild 和 CodeCommit 存储库作为 npm 依赖项
在 Angular + Electron 应用程序中使用 sqlite3:关键依赖项:依赖项的请求是一个表达式
Spring Boot 无法从 Spring Cloud AWS Core 依赖项启动