我正在运行以下命令sudo npm install node-sass --save-dev
,但进程失败并出现以下错误:-
build dir attempting to create "build" dir: /home/anit/Desktop/theInjuredLion/natours/node_modules/node-sass/build gyp ERR! configure error gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/anit/Desktop/theInjuredLion/natours/node_modules/node-sass/build' gyp ERR! System Linux 4.15.0-58-generic gyp ERR! command "/usr/bin/node" "/home/anit/Desktop/theInjuredLion/natours/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" gyp ERR! cwd /home/anit/Desktop/theInjuredLion/natours/node_modules/node-sass gyp ERR! node -v v8.10.0 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok Build failed with error code: 1
答案1
我认为您需要重新获得 .npm 目录的所有权。
sudo chown -R $(User) ~/.npm
并且需要node_modules目录的写权限:
sudo chown -R $(User) /home/anit/Desktop/
或者
sudo chown -R $(User) /home/anit/Desktop/theInjuredLion/natours/