500 FUNCTION_INVOCATION_FAILED
Unanswered
Pyramid ant posted this in #help-forum
Pyramid antOP
Hello, i am having this error when deploying my project to vercel, which does not happen on local development servers, i have tried everything but cant get it fixed. Thanks for anyone who might know how to fix this:
(node:4) Warning: Failed to load the ES module: /var/task/index.js. Make sure to set "type": "module" in the nearest package.json file or use the .mjs extension.
(Use
(node:4) Warning: Failed to load the ES module: /var/task/index.js. Make sure to set "type": "module" in the nearest package.json file or use the .mjs extension.
/var/task/index.js:1
import "dotenv/config";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (node:internal/modules/cjs/loader:1861:18)
at Module.<anonymous> (node:internal/modules/cjs/loader:1903:20)
at L.m._compile (/opt/rust/bytecode.js:2:5035)
at Object..js (node:internal/modules/cjs/loader:2060:10)
at Module.load (node:internal/modules/cjs/loader:1651:32)
at Module.<anonymous> (node:internal/modules/cjs/loader:1443:12)
at /opt/rust/nodejs.js:2:14482
at Module.Eo (/opt/rust/nodejs.js:2:14860)
at e.<computed>.ut._load (/opt/rust/nodejs.js:2:14452)
at wrapModuleLoad (node:internal/modules/cjs/loader:261:19)
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.
(node:4) Warning: Failed to load the ES module: /var/task/index.js. Make sure to set "type": "module" in the nearest package.json file or use the .mjs extension.
(Use
node --trace-warnings ... to show where the warning was created)(node:4) Warning: Failed to load the ES module: /var/task/index.js. Make sure to set "type": "module" in the nearest package.json file or use the .mjs extension.
/var/task/index.js:1
import "dotenv/config";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (node:internal/modules/cjs/loader:1861:18)
at Module.<anonymous> (node:internal/modules/cjs/loader:1903:20)
at L.m._compile (/opt/rust/bytecode.js:2:5035)
at Object..js (node:internal/modules/cjs/loader:2060:10)
at Module.load (node:internal/modules/cjs/loader:1651:32)
at Module.<anonymous> (node:internal/modules/cjs/loader:1443:12)
at /opt/rust/nodejs.js:2:14482
at Module.Eo (/opt/rust/nodejs.js:2:14860)
at e.<computed>.ut._load (/opt/rust/nodejs.js:2:14452)
at wrapModuleLoad (node:internal/modules/cjs/loader:261:19)
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.
4 Replies
Thanks for providing the whole error. The solution is alr in your error:
So add “type: module” in your package json. OR rename /var/task/index.js to /var/task/index.mjs
(node:4) Warning: Failed to load the ES module: /var/task/index.js. Make sure to set "type": "module" in the nearest package.json file or use the .mjs extension.
So add “type: module” in your package json. OR rename /var/task/index.js to /var/task/index.mjs
@B33fb0n3 Thanks for providing the whole error. The solution is alr in your error:
> (node:4) Warning: Failed to load the ES module: /var/task/index.js. Make sure **to set "type": "module" in the nearest package.json** file or use the .mjs extension.
So add “type: module” in your package json. OR rename /var/task/index.js to /var/task/index.mjs
Pyramid antOP
I already have type: module in the package.json , nothing seems to help. Locally in vscode when i start the dev server with "vercel dev" everything works just fine
@Pyramid ant I already have type: module in the package.json , nothing seems to help. Locally in vscode when i start the dev server with "vercel dev" everything works just fine
is that index.js file your file? Or is it part of any node modules or dependency or whatever?
Pyramid antOP
I initialized the backend now again but with the vercel express template, and now it works just fine. I suppose there was something wrong with the package.json / tsconfig etc. Thanks for trying to help me though, this took way too long 💀