Site Name: https://angry-heyrovsky-52f67d.netlify.app
Build Log: Netlify App
I use NextJS, and there I have an API to upload a file which is then saved using formidable
. But when I send a POST request to this endpoint, it throws a bad gateway but when I go to it normally, it says it can’t find the node:fs
module.
https://angry-heyrovsky-52f67d.netlify.app/api/uploadFile
{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'node:fs'\nRequire stack:\n- /var/task/nextPage/pages/api/uploadFile.js\n- /var/task/next_api_uploadFile.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js","trace":["Runtime.ImportModuleError: Error: Cannot find module 'node:fs'","Require stack:","- /var/task/nextPage/pages/api/uploadFile.js","- /var/task/next_api_uploadFile.js","- /var/runtime/UserFunction.js","- /var/runtime/index.js"," at _loadUserApp (/var/runtime/UserFunction.js:100:13)"," at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)"," at Object.<anonymous> (/var/runtime/index.js:43:30)"," at Module._compile (internal/modules/cjs/loader.js:999:30)"," at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)"," at Module.load (internal/modules/cjs/loader.js:863:32)"," at Function.Module._load (internal/modules/cjs/loader.js:708:14)"," at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)"," at internal/main/run_main_module.js:17:47"]}
On my localhost everything works fine.
I have NodeJS v16, and the build log says so
10:11:55 AM: v16.13.1 is already installed.
10:11:56 AM: Now using node v16.13.1 (npm v8.1.2)