Updated title from
Netlify.toml written at npm "postinstall" not being detected by build engine fro clarity
In my current use case, I am trying to write a custom
netlify.toml before each build. There are multiple reasons why, but the most important reasons are:
- I cant track
netlify.tomlon git (this is on purpose)
- I want to make sure end-users don’t change or overwrite our
netlify.tomlhave custom build plugins
I have configured a
"postinstall" script which executes the command:
node --eval "require('@myprivateorg/netlify-toml')"
This command effectively writes a
netlify.toml to the root of the project. This works perfectly fine locally.
Unfortunately, despite the fact that the command executes successfully after the project dependencies are installed , it appears that it’s somehow written too late for the netlify build engine to detect it. i.e our netlify.toml config is being ignored and our custom plugins are not being loaded.
7:39:51 AM: [5/5] Building fresh packages... 7:39:57 AM: $ node --eval "require('@myorg/netlify-toml')" 7:39:59 AM: Created default netlify.toml at /opt/build/repo <------ ✅ 7:39:59 AM: Done in 61.65s. 7:39:59 AM: NPM modules installed using Yarn 7:39:59 AM: Started restoring cached go cache 7:39:59 AM: Finished restoring cached go cache 7:39:59 AM: go version go1.14.4 linux/amd64 7:39:59 AM: go version go1.14.4 linux/amd64 7:39:59 AM: Installing missing commands 7:39:59 AM: Verify run directory 7:40:00 AM: 7:40:00 AM: ──────────────────────────────────────────────────────────────── 7:40:00 AM: Netlify Build 7:40:00 AM: ──────────────────────────────────────────────────────────────── 7:40:00 AM: 7:40:00 AM: ❯ Version 7:40:00 AM: @netlify/build 17.9.2 7:40:00 AM: 7:40:00 AM: ❯ Flags 7:40:00 AM: baseRelDir: true 7:40:00 AM: deployId: 61128f70de851d43819b2cb8 7:40:00 AM: 7:40:00 AM: ❯ Current directory 7:40:00 AM: /opt/build/repo 7:40:00 AM: 7:40:00 AM: ❯ Config file <--- 🚫 Not detecting the netlify.toml we just wrote 7:40:00 AM: No config file was defined: using default values. 7:40:00 AM: 7:40:00 AM: ❯ Context 7:40:00 AM: production 7:40:00 AM: 7:40:00 AM: ❯ Loading plugins <---- 🚫 Not detecting our netlify.toml build plugins 7:40:00 AM: - @firstname.lastname@example.org from Netlify app and package.json 7:40:00 AM: <--- ⚠️ running because its also added via the UI but ignoring our version
2:15:54 PM: ❯ Loading plugins
2:15:54 PM: - @email@example.com from netlify.toml and package.json
2:15:54 PM: - @firstname.lastname@example.org from netlify.toml and package.json
2:15:54 PM: - @email@example.com from netlify.toml and package.json
FULL DEPLOYMENT LOGS
Full failing deploy logs @ deploy id
Am i doing this wrong?
Is there a way to run a script before the netlify build engine kicks in?
Thanks for your help