安装vu3 pinia报错:(node:12974) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token ‘??=‘

报错:

 % npm run dev      

> [email protected] dev /Users/.../Documents/data/project/vue_case/vue3-pinia-demo
> vite

(node:12974) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token '??='
    at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:12974) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:12974) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

发现是node.js不兼容的问题

nvm ls

% nvm ls
->     v14.18.1
         system
default -> 14.18.1 (-> v14.18.1)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v14.18.1) (default)
stable -> 14.18 (-> v14.18.1) (default)
lts/* -> lts/iron (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.19.0 (-> N/A)
lts/iron -> v20.10.0 (-> N/A)

nvm i 18.19.0

% nvm i 18.19.0
Downloading and installing node v18.19.0...
Downloading https://nodejs.org/dist/v18.19.0/node-v18.19.0-darwin-arm64.tar.xz...
############################################################################# 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v18.19.0 (npm v10.2.3)

nvm use 18.19.0

 % nvm use 18.19.0
Now using node v18.19.0 (npm v10.2.3)

npm run dev

% npm run dev    

> [email protected] dev
> vite


  VITE v5.0.8  ready in 896 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help

升级node.js版本就解决了

你可能感兴趣的:(前端报错bug,前端,报错,bug)