Ошибка Npm "Ошибка: EACCES: разрешение запрещено, mkdir '../node-sass/build'" - PullRequest
2 голосов
/ 13 апреля 2019

Не удается установить пакет node-sass через npm sudo npm i, я пытался разрешить через sudo npm i -g node-sass --unsafe-perm=true --allow-root, но это не сработало. Chmod 777 тоже нет. Я думаю, что есть что-то с разрешениями npm, но я не знаю, Войти:

gyp verb build dir attempting to create "build" dir: /home/michael/Desktop/react/node_modules/node-sass/build
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/michael/Desktop/react/node_modules/node-sass/build'
gyp ERR! System Linux 4.15.0-47-generic
gyp ERR! command "/usr/bin/node" "/home/michael/Desktop/react/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/michael/Desktop/react/node_modules/node-sass
gyp ERR! node -v v11.14.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.11.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@4.11.0 postinstall 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!     /home/michael/.npm/_logs/2019-04-13T17_21_20_424Z-debug.log

1 Ответ

3 голосов
/ 13 апреля 2019

Как общая рекомендация, никогда не запускайте npm install с помощью sudo, так как он создаст локальные файлы, принадлежащие пользователю root, а не вашему пользователю. Я думаю, вы должны попробовать следующее:

  • Сначала смените владельцапапку: chown -R yourusername:yourusername /home/michael/Desktop/react/, или если вы не хотите вводить свое имя пользователя: chown -R $USER:$USER /home/michael/Desktop/react/
  • , затем запустите: npm install node-sass, не используйте sudo
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...