Local builds and runs but fails in cloud with same NODE_VERSION
.
NODE_VERSION=16.17.0
is used on local and in Netlify deploy environment variables
The failed dependency (canvas
) is pulled in from svelte-pdf-simple
, so we know the source of the problem, but where should we look for an indication about what is different in our local that causes it to build, from the Netlify build, where the dependency is not found?
package.json
:
...
"type": "module",
"dependencies": {
"@fortawesome/free-regular-svg-icons": "^6.0.0",
"cookie": "^0.4.1",
"encoding": "^0.1.13",
"fathom-client": "^3.1.0",
"faunadb": "^4.7.0",
"graphql": "^15.7.2",
"graphql-combine-query": "^1.2.3",
"mini-signals": "^1.2.0",
"node-fetch": "^3.1.0",
"sib-api-v3-sdk": "^8.3.0",
"svelte-fa": "^2.4.0",
"svelte-pdf-simple": "^2.0.0",
"uuid": "^8.3.2"
}
}
After npm -install
, package-lock.json
is checked in
Builds run locally complete and run without error
npm run build
npm run dev
all good on local but fails in the Netlify build:
8:50:36 PM: A Netlify Function failed to require one of its dependencies.
8:50:36 PM: Please make sure it is present in the site's top-level "package.json".
8:50:36 PM: In file "/opt/build/repo/.netlify/functions-internal/render.js"
8:50:36 PM: Cannot find module 'canvas'
8:50:36 PM: Require stack:
Netlify deploy Environment variable NODE_VERSION=16.17.0
, same as local.
Obviously the problem is a missing dependency (canvas) introduced by svelte-pdf-simple, but there shouldn’t there be some evidence of the discrepancy between the successful local build and failed Netlify build?
netlify.toml is
[build]
command = “npm run build”
publish = “build”
functions = “functions”
Thanks!