npm install 权限问题

npm ERR! Error: EACCES: permission denied, access ‘/Users/Lobin/work/note-vue/node_modules/@babel/highlight/node_modules/chalk‘
npm ERR!  { Error: EACCES: permission denied, access ‘/Users/Lobin/work/note-vue/node_modules/@babel/highlight/node_modules/chalk‘
npm ERR!   stack: ‘Error: EACCES: permission denied, access \‘/Users/Lobin/work/note-vue/node_modules/@babel/highlight/node_modules/chalk\‘‘,
npm ERR!   errno: -13,
npm ERR!   code: ‘EACCES‘,
npm ERR!   syscall: ‘access‘,
npm ERR!   path: ‘/Users/Lobin/w

解决方案:官方链接

https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

docs homecontact supportnpm.communitynpmjs.com

Packages and modules > Getting packages from the registry

Resolving EACCES permissions errors when installing packages globally

If you see an EACCES error when you try to install a package globally, you can either:

  • Reinstall npm with a node version manager (recommended),

or

  • Manually change npm’s default directory

Reinstall npm with a node version manager§

This is the best way to avoid permissions issues. To reinstall npm with a node version manager, follow the steps in “Downloading and installing Node.js and npm”. You do not need to remove your current version of npm or Node.js before installing a node version manager.

Manually change npm’s default directory§

Note: This section does not apply to Microsoft Windows.

To minimize the chance of permissions errors, you can configure npm to use a different directory. In this example, you will create and use hidden directory in your home directory.

  1. Back up your computer.
  2. On the command line, in your home directory, create a directory for global installations:
     mkdir ~/.npm-global
    
  3. Configure npm to use the new directory path:
     npm config set prefix ‘~/.npm-global‘
    
  4. In your preferred text editor, open or create a ~/.profile file and add this line:
     export PATH=~/.npm-global/bin:$PATH
    
  5. On the command line, update your system variables:
     source ~/.profile
    
  6. To test your new configuration, install a package globally without using sudo:
     npm install -g jshint
    

Instead of steps 2-4, you can use the corresponding ENV variable (e.g. if you don’t want to modify ~/.profile):

    NPM_CONFIG_PREFIX=~/.npm-global

npx: an alternative to running global commands

If you are using npm version 5.2 or greater, you may want to consider npx as an alternative way to run global commands, especially if you only need a command occasionally. For more information, see this article about npx.


< Downloading and installing packages globally | Updating packages downloaded from the registry >

The current stable version of npm is here. To upgrade, run: npm install [email protected] -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

原文地址:https://www.cnblogs.com/lobin/p/10193261.html

时间: 2024-08-29 17:37:30

npm install 权限问题的相关文章

npm install -g 全局安装总是出现permission权限问题的解决方案

开始使用node的时候,在使用npm安装global packages时,习惯性地使用npm install -g xxx,然后总是提示权限问题,安装失败. 需要使用sudo.这问题确实让我比较窝火.一个package完全没有必要放入到需要特殊权限的/usr/local/目录,于是想办法解决它. 这里提供一种解决方案,将npm的global package安装路径放入到当前用户的home目录下,避免使用sudo,一样可以安装global的npm package: #brew install no

OSX El Capitan node-5.0.0下sudo npm install遇到的权限问题

虽然不建议使用sudo安装npm包,但你往往不可避免去这么⊙﹏⊙b汗. 例如我们要去安装fisp这个npm包  $ sudo cnpm install -g fis-plus 结果首行报错是: gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/ xxx/.node-gyp/5.0.0" 明显的权限问题嘛!但是我用了sudo( ⊙o⊙ )哇!!! 于是去

Mac环境下执行npm install报权限错误解决办法

1. 一般情况 sudo npm install 2. 特殊情况 npm install --unsafe -perm 3. 究极情况 sudo npm install --unsafe -perm 原文地址:https://www.cnblogs.com/similar/p/11247327.html

window环境下npm install node-sass报错

最近准备想用vue-cli初始化一个项目,需要sass-loader编译: 发现window下npm install node-sass和sass-loader一直报错, window 命令行中提示我全局安装 node-gyp ,有些提示好像是本地找不到python, 于是我按照提示安装node-gyp node-gyp是一个用Node.js编写的跨平台命令行工具,用于编译Node.js的本地插件模块. node-gyp node-gyp官方网址https://www.npmjs.com/pac

使用npm install报错-4048 operation not permitted解决

刚刚使用npm install时一直报错-4048 operation not permitted,也尝试了多种方法,终于使问题得到解决,这里总结几种方法,先贴图: 一:权限问题 首先看到operation not permitted我们能想到权限问题,所以这时候我们可以以管理员身份运行cmd或者直接快捷键Win+X来打开. 二:依赖包错误 如上图,根据错误日志我们可以明显看到这个错误minimatch版本过低和dashdash错误,我们只要全局安装好这两个包问题就可以得到完美解决. 当我们在n

npm install 报错(npm ERR! errno -4048,Error: EPERM: operation not permitted,)解决方法

npm ERR! path E:\SouthernPowerGridProject\web_project\AutoOPS\autoops\node_modules\fsevents\node_modules\dashdash\node_modulesnpm ERR! code EPERMnpm ERR! errno -4048npm ERR! syscall scandirnpm ERR! Error: EPERM: operation not permitted, scandir 'E:\S

1.在cmd界面搭建react-native 环境: 可参考https://reactnative.cn/docs/0.51/getting-started.html#content   (1)npm install -g yarn react-native-cli       安装yarn命令工具和react-native命令工具,Yarn是Facebook提供的替代npm的工具,可以加速n

http://www.bubuko.com/infodetail-2599307.html 1.在cmd界面搭建react-native 环境: 可参考https://reactnative.cn/docs/0.51/getting-started.html#content (1)npm install -g yarn react-native-cli 安装yarn命令工具和react-native命令工具,Yarn是Facebook提供的替代npm的工具,可以加速node模块的下载. Reac

使用npm install报错- operation not permitted解决

原文:https://blog.csdn.net/weixin_41715295/article/details/79508104 这几天使用npm install时一直报错-4048 operation not permitted,也尝试了多种方法,终于使问题得到解决,这里总结几种方法,先贴图:  一:权限问题 首先看到operation not permitted我们能想到权限问题,所以这时候我们可以以管理员身份运行cmd或者直接快捷键Win+X来打开. 二:依赖包错误 如上图,根据错误日志

npm install 时遇到的 python 问题

gyp ERR! configure error gyp ERR! stack Error: Python executable "python" is v2.4.3, which is not supported by gyp.gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.gyp ERR! stack     at failPythonV