我已经设置了一个Aws Ec2
实例来托管我的Node.js应用程序。当我使用sudo npm i
安装所有软件包时,从git repo克隆了项目之后,因此在完成软件包安装之前,它会给出这样的错误
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir
'/home/ubuntu/directory-server/node_modules/weak/build'
gyp ERR! System Linux 4.15.0-1021-aws
gyp ERR! command "/usr/bin/node"
"/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ubuntu/directory-server/node_modules/weak
gyp ERR! node -v v11.10.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
这是我的package.json
{
"name": "faunder",
"version": "0.0.1",
"description": "Faunder",
"main": "index.js",
"scripts": {
"clean": "rimraf -rf build && mkdir build",
"build": "babel src -d build && npm run build:copy",
"build:copy": "cp src/conf/config.ini build/conf/config.ini && cp -r
src/static build/ && cp src/api/handlers/logo-orange.png
build/api/handlers/logo-orange.png",
"build:deploy": "npm run clean && npm run build && pm2 start
build/index.js",
"start": "nodemon src/index.js --exec babel-node --presets env"
},
"author": "shayan.ahmed@utf-labs.com",
"license": "ISC",
"dependencies": {
"babel-preset-env": "^1.6.1",
"cookie-parser": "^1.4.3",
"cors": "^2.8.5",
"count-files": "^2.6.2",
"csvjson": "^5.0.0",
"csvtojson": "^2.0.8",
"dynamic-html-pdf": "0.0.4",
"express": "^4.16.2",
"fs-extra": "^7.0.1",
"htmltopdf": "0.0.8",
"image-to-base64": "^2.0.1",
"ini": "^1.3.5",
"json2csv": "^4.1.6",
"jsonwebtoken": "^8.3.0",
"lodash": "^4.17.10",
"md5": "^2.2.1",
"moment": "^2.21.0",
"mongodb": "^3.0.0-rc0",
"mqtt": "^2.14.0",
"multer": "^1.4.1",
"mysql2": "^1.5.1",
"node-async-loop": "^1.2.2",
"node-dir": "^0.1.17",
"node-schedule": "^1.3.0",
"nodemailer": "^4.6.8",
"nodemon": "^1.18.1",
"rimraf": "^2.6.3",
"save-dev": "^2.0.0",
"sequelize": "^4.27.0"
},
"devDependencies" : {
"babel-cli" : "^6.26.0"
}
}
当我运行此命令sudo npm i
时,该命令完成了软件包的安装,但在此时之间失败了
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir
'/home/ubuntu/directory-server/node_modules/weak/build'
gyp ERR! System Linux 4.15.0-1021-aws
gyp ERR! command "/usr/bin/node"
"/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ubuntu/directory-server/node_modules/weak
gyp ERR! node -v v11.10.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
,然后继续完成其余包装的安装。但是由于在运行节点应用程序时出现故障,因此它引发了这样的错误
Error: Cannot find module 'weak'
0|index | at Function.Module._resolveFilename
(internal/modules/cjs/loader.js:613:15)
0|index | at Function.Module._load
(internal/modules/cjs/loader.js:539:25)
0|index | at Module.require (internal/modules/cjs/loader.js:667:17)
0|index | at require (internal/modules/cjs/helpers.js:20:18)
0|index | at new D (/home/ubuntu/directory-
server/node_modules/dnode/index.js:28:20)
0|index | at module.exports (/home/ubuntu/directory-
server/node_modules/dnode/index.js:8:12)
0|index | at /home/ubuntu/directory-
server/node_modules/phantom/phantom.js:174:13
0|index | at Server.handler (/home/ubuntu/directory-
server/node_modules/shoe/index.js:22:9)
0|index | at Server.emit (events.js:197:13)
0|index | at App.emit (/home/ubuntu/directory-
server/node_modules/sockjs/lib/sockjs.js:182:27)
0|index | at Session.emit_open (/home/ubuntu/directory-
server/node_modules/sockjs/lib/transport.js:107:23)
0|index | at processTicksAndRejections
(internal/process/next_tick.js:74:9) code: 'MODULE_NOT_FOUND' }
答案 0 :(得分:0)
该问题归因于EC2中的文件夹权限。 这是您可以尝试的可能解决方案
首先授予从{strong> git 克隆的文件夹的chmod 777
权限,然后
尝试sudo npm install
如果上述问题仍然无法解决,还可以将您的Node版本更新为8.x