SyntaxError: Cannot use import statement outside a module

This should be a simple error but I cannot seem to figure it out :thinking:
My project works fine locally.

Code:
Uploading: Screenshot 2023-08-06 at 11.07.02 AM.png…

Error:
SyntaxError: Cannot use import statement outside a module

My Command Settings:

What I tried:
-Local and Render node versions match (v18.7.0)
-Tried changing pubsub.js to pubsub.mjs, package.json to include “type”:“module”, none of which worked

Any help would be appreciated :pray:

Hey,

That appears to be an issue that isn’t exclusive to Render. The error messages you’re encountering suggest that the code is utilizing ES6 import syntax (import { something } from ‘somewhere’), but the Node runtime is interpreting the code as CommonJS, which doesn’t support that import syntax. There might be various reasons for this.

Have you made any modifications to your local setup? Have you verified that all your files are being compiled with Babel and that the correct JavaScript content is being served?

Jérémy.
Render Support, UTC+3

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.