Home > Blockchain >  VUE3: npm init throws error unexpected token
VUE3: npm init throws error unexpected token

Time:12-17

just started with the new Vue3 initialization (npm init vue@latest) and right out of the gate i get an error:

npx: installed 1 in 1.787s
C:\neard\tmp\npm-cache\_npx\10696\node_modules\create-vue\outfile.cjs:3896
  const isFeatureFlagsUsed = typeof (argv.default ?? argv.ts ?? argv.jsx ?? argv.router ?? argv.pinia ?? argv.tests ?? argv.vitest ?? argv.cypress ?? argv.playwright ?? argv.eslint) === "boolean";
                                                   ^

SyntaxError: Unexpected token '?'
    at wrapSafe (internal/modules/cjs/loader.js:1063:16)
    at Module._compile (internal/modules/cjs/loader.js:1111:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:996:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

have no idea where to begin troubleshooting this. brand new NodeJS install. you'll see from the path that i'm running neard as my stack BUT i do not have NodeJS running on it; i have it installed in the base machine. in fact i'm not running neard at all right now, it's just where i have all my projects.

anyway. any suggestions would be helpful. i've tried searching for a similar problem, but found nothing.

CodePudding user response:

From what you have provided it looks like there may be an issue with the version of Node.js you are using. The code you posted includes syntax that uses the "nullish coalescing operator" (??), which was introduced in Node.js 14.

Do

node -v

As this shouldn't be happening on the new build of node.js

So I recommend that you update to the latest node.js build: 19.2.0 as this should fix the current problem you are having.

  • Related