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.
1 Reply
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