当前位置:   article > 正文

mac cnpm安装失败及解决方案_| postinstall: info lifecycle xlsx@0.14.1~postinst

| postinstall: info lifecycle xlsx@0.14.1~postinstall: xlsx@0.14.1

1.首先要去配置node.js,直接去node.js官网(http://nodejs.cn/) 下载node-vx.x.x.pkg文件双击一路默认安装即可,安装完在终端输入:

node -v

如果显示版本号,如:8.9.0,说明安装成功

2.淘宝镜像安装cnpm,在终端输入:

npm install -g cnpm --registry=https://registry.npm.taobao.org

如果提示以下信息,说明安装失败:

npm ERR! Unexpected end of JSON input while parsing near '...ttachment":false,"tar'

npm ERR! A complete log of this run can be found in:

npm ERR!    /Users/***/.npm/_logs/2017-11-19T06_56_48_229Z-debug.log

3.如果出现上面的信息,不要慌,依次输入下面三行命令,第三行清除一下安装缓存:

npm set registry https://registry.npm.taobao.org

npm set disturl https://npm.taobao.org/dist

npm cache clean --force

4.上面三行命令完成后,再次输入步骤二的命令:

npm i -g cnpm --registry=https://registry.npm.taobao.org

如果一切正常,输入下面的命令,查询是否安装成功:

cnpm -v

如果出现下面的版本信息,说明cnpm安装成功

cnpm@5.1.1 (/usr/local/lib/node_modules/cnpm/lib/parse_argv.js)

npm@5.5.1 (/usr/local/lib/node_modules/cnpm/node_modules/npm/lib/npm.js)

node@8.9.0 (/usr/local/bin/node)

npminstall@3.2.1 (/usr/local/lib/node_modules/cnpm/node_modules/npminstall/lib/index.js)

prefix=/usr/local

darwin x64 16.7.0

registry=http://registry.npm.taobao.org

5.如果步骤4执行完命令后出现以下信息,说明安装失败,需要一个安装的最高权限:

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules

npm ERR! path /usr/local/lib/node_modules

npm ERR! code EACCES

npm ERR! errno -13

npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

npm ERR!  stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',

npm ERR!  errno: -13,

npm ERR!  code: 'EACCES',

npm ERR!  syscall: 'access',

npm ERR!  path: '/usr/local/lib/node_modules' }

npm ERR!

npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:

npm ERR!    /Users/lijia/.npm/_logs/2017-11-19T07_07_29_494Z-debug.log

这时,请输入一下命令:

sudo npm install -g cnpm --registry=https://registry.npm.taobao.org --verbose

此时会提示让你输入一个密码,即你的用户开机密码,输入回车即可,如果出现下面的信息(最下面几行)说明安装成功:

npm info lifecycle cnpm@5.1.1~postinstall: cnpm@5.1.1

npm verb unlock done using /Users/lijia/.npm/_locks/staging-3a08f0df5026584d.lock for /usr/local/lib/node_modules/.staging

+ cnpm@5.1.1

added 692 packages in 29.865s

npm verb exit [ 0, true ]

npm info ok

好了,输入下面的命令查询一下吧

cnpm -v



作者:浪流儿
链接:https://www.jianshu.com/p/e7071f4b3a57
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/98676
推荐阅读
相关标签
  

闽ICP备14008679号