所以我以 MacBook 的管理員身份登錄,并想在我的 Django 專案中運行 npm 命令。但是,由于缺少權限而拒絕。
(venv) jonas@Air-von-Jonas salaryx % npm install -g sass
npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/sass/sass.js
npm ERR! dest /usr/local/bin/sass
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/sass/sass.js' -> '/usr/local/bin/sass'
npm ERR! [Error: EACCES: permission denied, symlink '../lib/node_modules/sass/sass.js' -> '/usr/local/bin/sass'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '../lib/node_modules/sass/sass.js',
npm ERR! dest: '/usr/local/bin/sass'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jonas/.npm/_logs/2022-03-24T06_04_35_362Z-debug.log
(venv) jonas@Air-von-Jonas salaryx %
此外,似乎我無法更改檔案夾的權限,我可以解鎖右下角的鎖,但是一旦我嘗試更改“輪子”的權限,例如它也會拒絕。

uj5u.com熱心網友回復:
全域安裝 npm 包的一種簡單方法是使用sudo命令,如下所示:
sudo npm install -g sass
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/448518.html
