nrm安装过程及报错解决
打开powerShellnpm install rnm -g //下载全局包nrm运行nrm时报错:nrm : 无法加载文件 C:\Users\Lenovo\AppData\Roaming\npm\nrm.ps1,因为在此系统上禁止运行脚本。有关详细信息,请 参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Po
·
打开powerShell
npm install rnm -g //下载全局包nrm
运行nrm时报错:
nrm : 无法加载文件 C:\Users\Lenovo\AppData\Roaming\npm\nrm.ps1,因为在此系统上禁止运行脚本。有关详细信息,请 参阅 https:
/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ nrm ls
+ ~~~
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
解决方法:以管理员身份运行powershell
set-ExecutionPolicy RemoteSigned //修改执行策略,按Y确定
继续运行nrm ls时报错
[TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at validateString (internal/validators.js:124:11)
at Object.join (path.js:375:7)
at Object.<anonymous> (C:\Users\Lenovo\AppData\Roaming\npm\node_modules\nrm\cli.js:17:20)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
] {
code: 'ERR_INVALID_ARG_TYPE'
}
解决方法:查找nrm安装路径,输入:
npm root -g
寻找到nrm下的文件cli.js
#!/usr/bin/env node
const path = require('path');
const fs = require('fs');
const program = require('commander');
const npm = require('npm');
const ini = require('ini');
const echo = require('node-echo');
const extend = require('extend');
const open = require('open');
const async = require('async');
const request = require('request');
const only = require('only');
const registries = require('./registries.json');
const PKG = require('./package.json');
const NRMRC = path.join(process.env.HOME, '.nrmrc'); (删除)
将14行修改
//const NRMRC = path.join(process.env.HOME, '.nrmrc'); 将该行修改为下面那行
const NRMRC = path.join(process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'], '.nrmrc');
再次输入nrm ls
nrm ls
* npm -------- https://registry.npmjs.org/
yarn ------- https://registry.yarnpkg.com/
cnpm ------- http://r.cnpmjs.org/
taobao ----- https://registry.npm.taobao.org/
nj --------- https://registry.nodejitsu.com/
npmMirror -- https://skimdb.npmjs.com/registry/
edunpm ----- http://registry.enpmjs.org/
nrm use taobao //选择淘宝做为默认下载地址
更多推荐
所有评论(0)