简体   繁体   English

build() 调用中的无效选项:“watch”

[英]Invalid option in build() call: "watch"

I am following the example as it is described here:我正在按照此处描述的示例进行操作:

https://bilalbudhani.com/chokidar-esbuild/ https://bilalbudhani.com/chokidar-esbuild/

When I do:当我做:

node esbuild.config.js --watch

I get the message:我收到消息:

[ERROR] Invalid option in build() call: "watch"

I have no idea why this is happening.我不知道为什么会这样。

Is "watch" not longer a parameter? “手表”不再是参数了吗?

I also did this example:我也做了这个例子:

const path = require('path')

require("esbuild").build({
  entryPoints: ["application.js", "client.js"],
  bundle: true,
  sourcemap: true,
  outdir: path.join(process.cwd(), "app/assets/builds"),
  absWorkingDir: path.join(process.cwd(), "app/javascript"),
  minify: true,
  watch: true,
})
.then(() => console.log("⚡Done"))
.catch(() => process.exit(1));

If i remove the line "watch:true", it compiles ok.如果我删除“watch:true”行,它编译正常。 But if I leave it, I get the same error:但是如果我离开它,我会得到同样的错误:

Invalid option in build() call: "watch" build() 调用中的无效选项:“watch”

when I do: node esbuild.config.js当我这样做时:node esbuild.config.js

Thank you in advance先感谢您

Summing up from the comments:从评论中总结:

esbuild <v0.16 has removed the watch option. esbuild <v0.16 已删除watch选项。 Most tutorials and HowTos are pointing to that version.大多数教程和 HowTos 都指向该版本。 Downgrade your esbuild to that if you want to use it like described there.如果您想像那里描述的那样使用它,请将您的 esbuild 降级到那个版本。

Better option is to use esbuild >0.16 which has a built in live reload which combines watch and serve using the newly introduced context更好的选择是使用 esbuild >0.16,它有一个内置的实时重新加载,它使用新引入的上下文结合了watchserve

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM