为什么我在 modules.js 而 运行 METEOR 中出现 SytaxError?

Why am I getting SytaxError in modules.js while running METEOR?

启动 meteor 时出现以下错误。它在我的旧机器上运行良好,但现在无法运行。

W20190918-11:37:00.641(5)? (STDERR) /home/waqas/Documents/code-base/myproject/.meteor/local/build/programs/server/packages/modules.js:3284
W20190918-11:37:00.644(5)? (STDERR)             ...this._options,
W20190918-11:37:00.645(5)? (STDERR)             ^^^
W20190918-11:37:00.645(5)? (STDERR)           
W20190918-11:37:00.645(5)? (STDERR) SyntaxError: Unexpected token ...
W20190918-11:37:00.645(5)? (STDERR)     at Object.exports.runInThisContext (vm.js:53:16)
W20190918-11:37:00.646(5)? (STDERR)     at /home/waqas/Documents/code-base/myproject/.meteor/local/build/programs/server/boot.js:287:30
W20190918-11:37:00.646(5)? (STDERR)     at Array.forEach (native)
W20190918-11:37:00.646(5)? (STDERR)     at Function._.each._.forEach (/home/waqas/.meteor/packages/meteor-tool/.1.4.1_3.1ujjc8o.xamr++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20190918-11:37:00.647(5)? (STDERR)     at /home/waqas/Documents/code-base/myproject/.meteor/local/build/programs/server/boot.js:128:5

我正在使用这个命令来启动流星: meteor run --port 4000 --settings .config/development/settings.json(即使它不适用于 meteor 命令)

版本: Meteor 1.4.1.3 node: v10.16.3 npm 6.9.0

默认情况下,Meteor 不会在 node_modules 目录中 compile/transpile 文件,因此如果有节点捆绑版本(当前 8.15.1)不支持的代码,它会抛出一个 SyntaxError.

要解决这个问题,您可以通过将它符号链接到您的项目中来告诉 Meteor 您想要编译该模块,此时编译器会认为它是主项目的一部分并为您编译它。

或者,根据模块的不同,您可以直接导入模块内部的预编译版本。例如import 'example-module/dist/example.min.js'

我不能告诉你这是否适用于你的项目,因为你没有提供足够的细节


编辑:查看 feature compatibility table for node,rest/spread 语法 ... 在节点 8 中受支持,因此可能发生了其他奇怪的事情。

您能否提供更多详细信息,包括 Meteor 版本、您使用的 运行 它以及您使用的节点模块?


编辑 2:

感谢您发布您的 Meteor 版本。 Meteor 1.4.1.3 来了bundled with Node 4.6.1,再看那些表,显示不支持rest/spread。在这种情况下,不需要符号链接策略,因为我相信 node_modules 曾经由 1.4 编译。

您的项目中有 .babelrc 文件吗?
你能检查哪个节点模块包含问题语法吗? (查看此文件:/home/waqas/Documents/code-base/myproject/.meteor/local/build/programs/server/packages/modules.js:3284 看看是否可以找到内联的模块)