vue init webpack报错解决

1,使用vue init webpack创建Vue项目脚手架报错

bogon:~ Brave$ vue init webpack test
/usr/local/lib/node_modules/vue-cli/bin/vue-init:60
let template = program.args[0]
^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:404:25)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:457:10)
    at startup (node.js:136:18)
    at node.js:972:3

2,查看node版本

bogon:~ Brave$ node -v
v5.0.0

需要升级Node.js版本

3,安装n模块

bogon:~ Brave$ sudo npm install -g n
Password:
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
/usr/local/lib
└── n@2.1.8

4,升级node为最新稳定版:

bogon:~ Brave$ sudo n stable

    install : node-v9.2.1
      mkdir : /usr/local/n/versions/node/9.2.1
      fetch : https://nodejs.org/dist/v9.2.1/node-v9.2.1-darwin-x64.tar.gz
######################################################################## 100.0%
   installed : v9.2.1

5,重新创建项目脚手架,成功

bogon:~ Brave$ vue init webpack test

? Project name (test)

你可能感兴趣的:(Vue)