老师您好,我也是macOS系统,但是使用cnpm一直不能成功安装插件包,在之前的那个购物车课程中就是这样:
bogon:~ VitoYi$ cd /Users/mac/WebstormProjects/vue-demo1 bogon:vue-demo1 VitoYi$ cnpm i vue-cli -g Downloading vue-cli to /Users/mac/.node_modules_global/lib/node_modules/vue-cli_tmp [npminstall:get] retry GET http://registry.npm.taobao.org/vue-cli after 100ms, retry left 4, error: SyntaxError: Unexpected token < in JSON at position 0 [npminstall:get] retry GET http://registry.npm.taobao.org/vue-cli after 200ms, retry left 3, error: SyntaxError: Unexpected token < in JSON at position 0 [npminstall:get] retry GET http://registry.npm.taobao.org/vue-cli after 300ms, retry left 2, error: SyntaxError: Unexpected token < in JSON at position 0 [npminstall:get] retry GET http://registry.npm.taobao.org/vue-cli after 400ms, retry left 1, error: SyntaxError: Unexpected token < in JSON at position 0 SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse (<anonymous>) at _get (/Users/mac/.node_modules_global/lib/node_modules/cnpm/node_modules/npminstall/lib/get.js:70:26) at _get.next (<anonymous>) at onFulfilled (/Users/mac/.node_modules_global/lib/node_modules/cnpm/node_modules/co/index.js:65:19) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) npminstall version: 3.2.1 npminstall args: /usr/local/bin/node /Users/mac/.node_modules_global/lib/node_modules/cnpm/node_modules/npminstall/bin/install.js --china --userconfig=/Users/mac/.cnpmrc --disturl=https://npm.taobao.org/mirrors/node --registry=http://registry.npm.taobao.org vue-cli -g bogon:vue-demo1 VitoYi$
只能通过npm成功安装。
但是安装成功之后还有一个问题,就是不会自动加入环境变量吗?
在之前的购物车的课程中就是,使用
$ npm install cnpm -g --registry=https://registry.npm.taobao.org $ npm install http-server -g
命令安装 cnpm 和 http-server 之后不起作用,还需要我手动添加环境变量才可以。