首页 > 解决方案 > 在 Windows WSL2.0 上获取 SyntaxError: Unexpected token ...

问题描述

$ npm run dev

> moleculer-examples-conduit@3.0.0 dev /mnt/c/Users/pete/WebstormProjects/moleculer-examples/conduit
> moleculer-runner --repl services

/mnt/c/Users/pete/WebstormProjects/moleculer-examples/conduit/node_modules/moleculer/src/registry/registry.js:235
                                action.handler = this.broker.middlewares.wrapHandler("remoteAction", this.broker.transit.request.bind(this.b
roker.transit), { ...action, service });

                  ^^^
SyntaxError: Unexpected token ...
    at createScript (vm.js:53:10)
    at Object.runInThisContext (vm.js:95:10)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/mnt/c/Users/pete/WebstormProjects/moleculer-examples/conduit/node_modules/moleculer/src/registry/index.js:9:18)

npm ERR! Linux 5.4.72-microsoft-standard-WSL2
npm ERR! argv "/home/pete/.nvm/versions/node/v7.10.1/bin/node" "/home/saul/.nvm/versions/node/v7.10.1/bin/npm" "run" "dev"
npm ERR! node v7.10.1
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! moleculer-examples-conduit@3.0.0 dev: `moleculer-runner --repl services`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the moleculer-examples-conduit@3.0.0 dev script 'moleculer-runner --repl services'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the moleculer-examples-conduit package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     moleculer-runner --repl services
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs moleculer-examples-conduit
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls moleculer-examples-conduit
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/saul/.npm/_logs/2021-09-28T20_56_23_700Z-debug.log

有什么想法我在这里想念的吗?我也在 WSL 的其他项目中得到了这个。

标签: node.jswsl-2moleculer

解决方案


我听从了 Lawrence 的建议,更新了 Node

$ nvm use 14

现在它可以工作了。


推荐阅读