配置npm安装的全局模块所在的路径,以及缓存cache的路径
- 创建两个空文件夹【node_cache】和【node_global】
- 打开命令窗口(cmd)
npm config set prefix ""
npm config set cache ""
npm config get prefix
npm config get cache
3. 配置环境变量
(1)用户变量
(2)系统变量
VS Code中报错:无法加载文件 D:\nodejs\node_global\hs.ps1。因为在此系统上禁止运行脚本
- 关闭当下的vscode
- 以管理员身份允许vscode
- 执行:get-ExecutionPolicy,显示是Restricted,表示状态是禁止的;
- 执行:set-ExecutionPolicy RemoteSigned
- 此时再执行get-ExecutionPolicy,就显示RemoteSigned。
npm intasll 安装报错 Error: EPERM: operation not permitted
- 打开我们自己创建的【node_cache】和【node_global】两个文件夹的操作权限,具体操作如下所示: