Resolving EACCES permissions errors when installing packages globally(npm 遇到 write access的问题)...

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
 
# 第一步:在你的用户文件下新建一个文件夹,这个.npm-global 名字可以用你自己喜欢的名字替换,推荐直接使用这个名字。
mkdir ~/.npm-global
#第二步:更改node的安装连接
npm config set prefix '~/.npm-global'
#第三步:在用户的profile下增加path,为的是系统能够找到可执行文件的目录
 export PATH=~/.npm-global/bin:$PATH
#第四步:update profile。使其生效
source ~/.profile

 




转载于:https://www.cnblogs.com/landv/p/10897770.html

java.lang.LinkageError:loader constraint violation: when resolving method解释为加载器约束错误:在解析方法时。 当Java虚拟机(JVM)在运行时尝试加载类和解析类中的方法时,可能会遇到该错误。这通常发生在以下情况下: 1. 类型冲突:加载器尝试使用两个不同的类加载器加载具有相同名称但不同版本的类,从而导致了方法的冲突。因此,使用了不兼容的类定义。 2. 类重定义:加载器尝试重新定义已经在虚拟机中加载的类,从而导致加载的重复。这可能会导致类的冲突以及方法无法解析。 解决这个问题的方法如下: 1. 检查类加载器:确定是否有多个类加载器同时加载了相同的类。如果是,请确保只有一个类加载器加载相应的类。 2. 更新依赖关系:检查项目的依赖关系,确保所有的依赖项都是最新的版本并且兼容。 3. 清除类缓存:如果问题仍然存在,可以尝试清除JVM的类缓存。可以通过删除临时目录中的所有缓存文件来实现(例如,Java.io.tmpdir系统属性指向的目录)。 4. 更新JVM:确保使用的JVM是最新版本。有时,这种错误可能是由于JVM本身的问题引起的,而在较新的版本中可能已经修复。 总之,加载器约束错误是由于类加载器冲突或类重定义导致的,解决方法包括检查类加载器、更新依赖关系、清除类缓存以及更新JVM版本等。根据具体情况选择适当的解决方法。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值