如何让npm或sass全局安装?



我一直在看教程,到处搜索,我在这里看到了几个类似的问题。但没有一个有同样的错误。所以我很抱歉,如果这个问题之前已经回答过了。

我正在上一个自定进度的编程课。我应该安装sass。我终于找到了一个看起来很简单的教程。但是当我输入命令时,我在终端上得到错误代码。我对这一切都很陌生,所以我不知道这一切是什么意思。

一些上下文:我下载了homebrew,但也不明白(所以我卸载了它)。所以我按照这个教程下载了node.js/npm。一切都很顺利,直到我尝试了install -g sass命令。然后我开始收到所有这些信息,就像掉进了兔子洞。Npmjs.com有一些关于这个问题的信息,但我不明白。它提到重新安装npm,或者使用"nvm"但是当我尝试命令npm install -g npm时,它返回了非常类似的错误。

carlosprieto@Carloss-Mac-mini ~ % npm install -g sass
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/sass
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/sass'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/sass'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/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/carlosprieto/.npm/_logs/2022-06-17T16_02_28_018Z-debug-0.log

您需要管理权限,使用sudo应该可以帮助您

sudo npm i -g sass

这意味着您拥有超级用户权限,并且需要全局安装软件包。

阅读更多:https://www.tutorialspoint.com/unix_commands/sudo.htm

最新更新