Npm ERR! missing script: build

I’m trying to use my own build step, not using webpack. I also do not have a build script in my top level package.json…am I forced to have a build script in my top level package.json? It would be nice to not require this, or at least to be able to configure it

Building canisters...
Building frontend...
The post-build step failed for canister 'r7inp-6aaaa-aaaaa-aaabq-cai' with an embedded error: The command '"npm" "run" "build"' failed with exit status 'exit code: 1'.
Stdout:

Stderr:
npm ERR! missing script: build

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/lastmjs/.npm/_logs/2021-04-08T21_00_36_208Z-debug.log

dfx build for frontend defers npm run build. You can have an empty string as your build step.

3 Likes

If you don’t provide a package.json, dfx deploy succeeds just fine. If you add a package.json file without a build script, then it fails.

Can this requirement be removed in the future? Imagine a project with no build step, just raw HTML/CSS/JavaScript but still a package.json.

Could dfx check if a build script is present in the package.json, and not try to run it if it’s not there?

1 Like