public ActionResult Foo (FilterPageModel model){
//...
}
使用此命令以开发模式启动我的项目。输出为:
错误:未知选项-实验工作者”
config .babelrc:
babel-node --experimental-worker app.js
使用工作线程需要此标志。使用babel 6.26
答案 0 :(得分:2)
想法是将您的命令分为两个阶段:
阶段1:
babel app.js --out-file app-compiled.js
第2阶段:
node --experimental-worker app-compiled.js
然后在npm
脚本中可以将两者结合:
"scripts": {
"pre-build": "babel ./app.js --out-file ./app-compiled.js",
"serve": "yarn pre-build && node --experimental-worker ./app-compiled.js"
}
答案 1 :(得分:0)
我今天才遇到这个问题,并在GitHub here上回答了这个问题。我在下面粘贴了我的修复程序:
我当时使用的是Nodemon,事实证明,有一个选项可以 在
NODE_OPTIONS
中将环境变量作为nodemon.json
文件。这对我有用:{ "watch": ["server"], "ext": "js", "env": { "NODE_OPTIONS": "--experimental-worker" }, "exec": "babel-node server/server.js" }
如何将Nodemon +
worker_threads
集成到普通的NodeJS应用中:如果您是第一次设置Nodemon,我会发现 this教程非常有帮助。
答案 2 :(得分:0)
对我来说实际上已经不是。我被拒绝使用nodemon并使用命令
运行我的代码 node --experimental-worker -r babel-register $NODE_DEBUG_OPTION app.js
它可以帮助我将兼职人员与babel结合使用,但与nodemon结合使用-不是