Npm全局安装在VM中失败,因为缺少;注册处;?

Npm全局安装在VM中失败,因为缺少;注册处;?,npm,centos7,Npm,Centos7,我在一个虚拟机上工作,没有免费的互联网接入。我可以添加一个特定的注册表链接,这样使用npm安装即使在限制internet访问的情况下也不会出现任何问题。但是,当尝试使用npm-g安装执行相同操作时,它不起作用,问题似乎在于它没有使用我添加的注册表 npm ERR! Linux 4.19.49-1560253987 npm ERR! argv "/usr/bin/node" "/bin/npm" "-g" "install" "ganache-cli" npm ERR! node v6.16.0

我在一个虚拟机上工作,没有免费的互联网接入。我可以添加一个特定的注册表链接,这样使用npm安装即使在限制internet访问的情况下也不会出现任何问题。但是,当尝试使用npm-g安装执行相同操作时,它不起作用,问题似乎在于它没有使用我添加的注册表

npm ERR! Linux 4.19.49-1560253987
npm ERR! argv "/usr/bin/node" "/bin/npm" "-g" "install" "ganache-cli"
npm ERR! node v6.16.0
npm ERR! npm  v3.10.10
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! syscall getaddrinfo

npm ERR! network getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'
因为这也是我在没有添加注册表的情况下使用npm安装时收到的消息。只是现在只有全局安装才会发生这种情况

我会尝试在本地使用它,但它似乎需要在全局安装,因为当我尝试通过进入节点模块并执行脚本来使用命令行脚本时,它会给我: (松露是剧本的名字)

使用我试图安装的另一个软件包

$ node ganache-cli -g
/home/xxxxx/node_modules/ganache-cli/build/ganache-core.node.cli.js:47
!function(){var r,a={};function i(){}function o(e){return e}function c(e){return!!e}function s(e){return!e}var f="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||this;function d(e){return function(){if(null===e)throw new Error("Callback was already called.");e.apply(this,arguments),e=null}}function u(e){return function(){null!==e&&(e.apply(this,arguments),e=null)}}null!=f&&(r=f.async),a.noConflict=function(){return f.async=r,a};var l=Object.prototype.toString,b=Array.isArray||function(e){return"[object Array]"===l.call(e)};function p(e){return b(e)||"number"==typeof e.length&&e.length>=0&&e.length%1==0}function h(e,t){for(var r=-1,n=e.length;++r<n;)t(e[r],r,e)}function g(e,t){for(var r=-1,n=e.length,a=Array(n);++r<n;)a[r]=t(e[r],r,e);return a}function m(e){return g(Array(e),function(e,t){return t})}function v(e,t){for(var r=0;r<e.length;r++)if(e[r]===t)return r;return-1}var x=Objec

SyntaxError: missing ) after argument list
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/xxxxx/node_modules/ganache-cli/cli.js:12:13)

$node ganache cli-g
/home/xxxxx/node_modules/ganache cli/build/ganache core.node.cli.js:47

!函数(){var r,a={};函数i(){}函数o(e){return e}函数c(e){return!!e}函数s(e){return!e}var f=“object”==typeof self&&self.self==self&&self | |“object”==typeof global&&global.global==global&&global | this;函数d(e){&global&&global | |如果(null==e)抛出新错误(“回调已被调用);e.self=null),则应用参数(e)}函数u(e){return function(){null!==e&&(e.apply(this,arguments),e=null)}null!=f&(r=f.async),a.noConflict=function(){return f.async=r,a};var l=Object.protostring.toString,b=Array.isArray |函数(e){return[Object Array]“[Object Array]”==l.call(e)};函数p(e){return b(e)&&e)}number=typeof e.length==e.1240%t,e}(var r=-1,n=e.length;++r根本原因很可能是您的虚拟机时钟不同步,所以我会先检查一下。下面是我在centos上的工作原理:

第一次尝试:

yum install ntp
chkconfig ntpd on
ntpdate pool.ntp.org
service ntpd start
如果这不能解决您的问题,您可以(我警告您这是不安全的)尝试更改npm的配置

$ npm config set strict-ssl false
$ npm config set unsafe-perm true
$ npm config set registry http://registry.npmjs.org/

根本原因很可能是你的虚拟机时钟不同步,所以我会先检查一下。下面是我在centos上的工作原理:

第一次尝试:

yum install ntp
chkconfig ntpd on
ntpdate pool.ntp.org
service ntpd start
如果这不能解决您的问题,您可以(我警告您这是不安全的)尝试更改npm的配置

$ npm config set strict-ssl false
$ npm config set unsafe-perm true
$ npm config set registry http://registry.npmjs.org/