【发布时间】:2020-06-09 20:35:26
【问题描述】:
我已经在 AngularJS 中工作了一段时间,我决定尝试 Vue。我使用 Node 版本 6.4.0 在终端中使用 npm install -g @vue/cli 安装了 Vue。安装完成后,我尝试使用vue create <name of app> 创建一个新应用程序。正是在这个看似简单的步骤中,我被这个错误挂断了:
/Users/jonalden/.nvm/versions/node/v6.4.0/lib/node_modules/@vue/cli/node_modules/open/index.js:16
const wslToWindowsPath = async path => {
^^^^
SyntaxError: Unexpected identifier
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:528:28)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/jonalden/.nvm/versions/node/v6.4.0/lib/node_modules/@vue/cli/node_modules/@vue/cli-shared-utils/lib/openBrowser.js:9:14)
at Module._compile (module.js:556:32)
我曾尝试将 Node 降级到以前的版本并使用 Yarn 重新安装 Vue,但均不成功。让我失望的一件事是wslToWindowsPath 这行,因为我使用的是 Mac,所以这尤其奇怪。
【问题讨论】:
-
看来您使用的是旧版本的节点。尝试将节点升级到至少版本 12。
-
看来您至少需要 Node 版本 8.11.0
Currently, as of early 2019, to get the best results with Vue CLI, the minimum version of Node required is 8.11.0+, but you can kind of get by with 8.9 if you really have to.take from here -
节点版本是问题,谢谢!实际上,我之前已经下载了最新版本的 Node,但我正在为我的工作运行旧版本。我刚刚跑了
nvm install 12.0.0,它就像一个魅力。