I'm trying to use Vue.js 3 on Chrome OS (64-bit, v99) using code-server, using the official Vue installation guide, but when I run npm init vue@latest
I get the following error:
user@penguin ~/vue-project> npm init vue@latest
/home/user/.npm/_npx/2f7e7bff16d1c534/node_modules/create-vue/outfile.cjs:5894
const userAgent = process.env.npm_config_user_agent ?? "";
^
SyntaxError: Unexpected token '?'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47
npm ERR! code 1
npm ERR! path /home/user/vue-project
npm ERR! command failed
npm ERR! command sh -c create-vue
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2022-03-11T20_09_26_156Z-debug.log
user@penguin ~/vue-project [1]>
The error points to
??
, which is the nullish coallescing operator. Support for that operator was added in Node 14, but you're using Node 12 (based on your comment).The solution is to upgrade your Node version to Node 14 or newer.