安裝cnpm后 cnpm -v卻找不到
首先確認一下 npm 下載包路徑:
一.查看npm的prefix和cache設置信息
1|npm config get prefix
2|npm config get cache
二.設置下載路徑和緩存路徑
1|npm config set prefix “usr/example” 2|npm config set cache “usr/example“
三.查看npm配置下信息
1|npm config list
然后配置cnpm的環境變量
環境變量 :記錄電腦各種內容的位置
如何設置 : export PATH=path1/example:$PATH
一.新建並打開 .bash_profile 文件
1|cd ~ 2|touch .bash_profile 3|open .bash_profile
二.添加cnpm的路徑 保存 退出,設置全局路徑
1|export PATH=$PATH:/Users/你的用戶/example/bin
2|source .bash_profile
通常node和npm命令都安裝在 usr/local/bin路徑下,如果不將這個路徑添加到path變量里,通
過npm安裝的的各種包都會not found;所以要記得操作:
export PATH="$PATH:/usr/local/bin"