Manjaro配置nodejs環境


參考

https://blog.csdn.net/wsxwang/article/details/104706220

環境

  1. manjaro 19.0 xfce版

  2. openjdk 1.8.0_241

  3. VsCode 1.42.1


     

#nodejs安裝
sudo pacman -S nodejs
#npm安裝
sudo pacman -S npm
#設置npm源
npm config set registry https://registry.npm.taobao.org
#查看源是否更改成功
npm config get registry

nodejs設置

   vscode安裝vetur插件。


 

如果提示源有問題,可以更新

sudo pacman-mirrors -i -c China -m rank
sudo pacman-mirrors -g
sudo pacman -Sy #僅同步源
sudo pacman -S archlinuxcn-keyring
sudo pacman -S antergos-keyring

 


安裝vue環境報錯解決辦法

npm install -g vue

  報錯如下:

[xxx@manjaro ~]$ npm install vue -g
npm WARN checkPermissions Missing write access to /usr/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/usr/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/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!     /home/xxx/.npm/_logs/2021-01-16T18_24_19_878Z-debug.log

  解決辦法

2.改變npm默認的路徑。
步驟如下:
進入終端,依次輸入一下命令
(1)創建global安裝任務的目錄
mkdir ~/.npm-global
(2)配置npm使用新的目錄
npm config set prefix '~/.npm-global'3)在~/.profile文件中增加配置
export PATH=~/.npm-global/bin:$PATH
(4)配置文件立即生效
# source ~/.profile
source ./.bash_profile #manjaro使用此命令 (
5)重新執行命令 npm install -g xxxx

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM