Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js node pre gyp--安装canvas模块时返回生成错误_Node.js_Amazon Web Services_Canvas_Elasticbeanstalk_Node Pre Gyp - Fatal编程技术网

Node.js node pre gyp--安装canvas模块时返回生成错误

Node.js node pre gyp--安装canvas模块时返回生成错误,node.js,amazon-web-services,canvas,elasticbeanstalk,node-pre-gyp,Node.js,Amazon Web Services,Canvas,Elasticbeanstalk,Node Pre Gyp,在将我的项目部署到ElasticBeanStalk时,我遇到了一些问题。在安装canvas 2.7.0模块时,存在节点预gyp--返回到构建错误 我不确定这是否是权限错误,原因如下 Error: EACCES: permission denied, mkdir '/var/app/staging/node_modules/@tensorflow/tfjs-node/deps' 这里是我在eb-engine.log中的错误 > canvas@2.6.1 install /var/app/

在将我的项目部署到ElasticBeanStalk时,我遇到了一些问题。在安装canvas 2.7.0模块时,存在节点预gyp--返回到构建错误

我不确定这是否是权限错误,原因如下

 Error: EACCES: permission denied, mkdir '/var/app/staging/node_modules/@tensorflow/tfjs-node/deps'
这里是我在eb-engine.log中的错误

> canvas@2.6.1 install /var/app/staging/node_modules/canvas
> node-pre-gyp install --fallback-to-build

Failed to execute '/opt/elasticbeanstalk/node-install/node-v14.16.0-linux-x64/bin/node /opt/elasticbeanstalk/node-install/node-v14.16.0-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/var/app/staging/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/var/app/staging/node_modules/canvas/build/Release --napi_version=7 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)

2021/04/29 17:18:19.518886 [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:(node:3446) UnhandledPromiseRejectionWarning: Error: EACCES: permission denied, mkdir '/var/app/staging/node_modules/@tensorflow/tfjs-node/deps'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:3446) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3446) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
node-pre-gyp WARN Using needle for node-pre-gyp https download 
node-pre-gyp WARN Pre-built binaries not installable for canvas@2.6.1 and node@14.16.0 (node-v83 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/canvas/build' 
gyp WARN EACCES current user ("healthd") does not have permission to access the dev dir "/root/.cache/node-gyp/14.16.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/var/app/staging/node_modules/canvas/.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/canvas/.node-gyp'
gyp ERR! System Linux 4.14.225-169.362.amzn2.x86_64
gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v14.16.0-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v14.16.0-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/var/app/staging/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/var/app/staging/node_modules/canvas/build/Release" "--napi_version=7" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v83"
gyp ERR! cwd /var/app/staging/node_modules/canvas
gyp ERR! node -v v14.16.0
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-v14.16.0-linux-x64/bin/node /opt/elasticbeanstalk/node-install/node-v14.16.0-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/var/app/staging/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/var/app/staging/node_modules/canvas/build/Release --napi_version=7 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/var/app/staging/node_modules/canvas/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:1048:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
node-pre-gyp ERR! System Linux 4.14.225-169.362.amzn2.x86_64
node-pre-gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v14.16.0-linux-x64/bin/node" "/var/app/staging/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /var/app/staging/node_modules/canvas
node-pre-gyp ERR! node -v v14.16.0
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok 
npm WARN only4laugh@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
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! code ELIFECYCLE
npm ERR! errno 1
npm ERR! canvas@2.6.1 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the canvas@2.6.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

我知道这是权限错误,当服务器端npm安装命令运行时,ec2实例没有创建任何文件夹的权限,因此我找到了两个解决方案,第一个是create.npmrc file并将unsafe perm设置为true,另一个是create.ebextension file并设置根权限

"engines": {
    "node": ">=8.12.0",
    "npm": ">=6.0.0"
  }