简体   繁体   中英

Invalid option in build() call: "watch"

I am following the example as it is described here:

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. But if I leave it, I get the same error:

Invalid option in build() call: "watch"

when I do: node esbuild.config.js

Thank you in advance

Summing up from the comments:

esbuild <v0.16 has removed the watch option. Most tutorials and HowTos are pointing to that version. Downgrade your esbuild to that if you want to use it like described there.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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