【问题标题】:Why is permission denied in terminal when I tried to install sass using node.js当我尝试使用 node.js 安装 sass 时,为什么终端中的权限被拒绝
【发布时间】:2020-07-31 05:27:00
【问题描述】:

为什么我不能安装?帮助!我按照本教程进行操作,它告诉我安装 node.js,我照做了。

karenchan:~ karenchan$ npm install -g sass
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules'
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/karenchan/.npm/_logs/2020-07-30T20_33_04_760Z-debug.log
karenchan:~ karenchan$ npm install -g sass
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules'
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/karenchan/.npm/_logs/2020-07-30T20_44_30_523Z-debug.log
karenchan:~ karenchan$ 

【问题讨论】:

标签: node.js npm sass


【解决方案1】:

这就是问题所在:

Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

两种解决方案:

  1. 以“root”身份全局安装,使用sudo

    sudo npm install -g sass
    
  2. 在本地安装(因此“权限”应该不是问题):

    cd <<my project>>
    npm install sass
    

仅供参考,其他选项可能包括:

这是关于后者的一个很好的教程:

Installing Node.js Tutorial: Using nvm, Tierney Cyren

【讨论】:

  • 我试过你的第二种方法,“密码”这个词出现了一个图标,这是什么意思?然后我不能输入任何东西
  • YAYY 成功了,非常感谢
猜你喜欢
  • 2020-05-01
  • 2012-02-24
  • 1970-01-01
  • 2016-03-13
  • 1970-01-01
  • 2016-02-21
  • 2021-02-10
  • 2020-11-27
  • 1970-01-01
相关资源
最近更新 更多