Netlify site name: https://avi12-website.netlify.app
Ever since PNPM’s requirement with version 7 to support Node 14 or above, my build fails, as Netlify only supports Node 12
I’m wondering whether I should switch to NPM or not in the meantime.
Hi there, node 14+ is not a problem, you’ll just need to set it explicitly.
From our documentation:
Did you try doing what the error suggests? That is, add one of the flags to npm
?
You can do it as explained here: Manage build dependencies | Netlify Docs
What about the npm ERR! EEXIST: file already exists, mkdir '/dev/null'
part?
After switching to Node 14, I get a different error:
Basically, despite the onPreBuild
script installing PNPM, it fails to run.
module.exports = {
async onPreBuild({ utils: { build, run, status } }) {
try {
if (process.env.CI) {
await run.command("npx pnpm install -r --shamefully-hoist --store=node_modules/.pnpm-store");
} else {
status.show({ summary: "CI is false, skipping pnpm install." });
}
status.show({ summary: "Installed pnpm!" });
} catch (e) {
build.failBuild(`An error occurred while installing pnpm: ${e.message}`);
}
}
};
I ended up fixing the issue by:
- changing the
onPreBuild
script tomodule.exports = { async onPreBuild({ utils: { build, run, status } }) { try { if (process.env.CI) { await run.command("npx pnpm i --shamefully-hoist"); } else { status.show({ summary: "CI is false, skipping pnpm install." }); } status.show({ summary: "Installed pnpm!" }); } catch (e) { build.failBuild(`An error occurred while installing pnpm: ${e.message}`); } } };
- setting in the
netlify.toml
[build] command = "npx pnpm build" ...
- setting an environment variable:
NODE_VERSION=14
1 Like