Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error [ERR_REQUIRE_ESM]: require() of ES Module #459

Open
farhanhu87 opened this issue Jun 30, 2024 · 4 comments
Open

Error [ERR_REQUIRE_ESM]: require() of ES Module #459

farhanhu87 opened this issue Jun 30, 2024 · 4 comments
Labels

Comments

@farhanhu87
Copy link

Hi Team,

I am facing below error when i run "node index.js"

warn: DeprecationWarning: The Parse Server option 'allowClientClassCreation' default will change to 'false' in a future version.
warn: DeprecationWarning: The Parse Server option 'allowExpiredAuthDataToken' default will change to 'false' in a future version.
warn: DeprecationWarning: The Parse Server option 'encodeParseObjectInCloudFunction' default will change to 'true' in a future version.
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/farhan/parse-server-example/cloud/main.js from /home/farhan/parse-server-example/node_modules/parse-server/lib/ParseServer.js not supported.
main.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename main.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /home/farhan/parse-server-example/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

at ParseServer.start (/home/farhan/parse-server-example/node_modules/parse-server/lib/ParseServer.js:146:13)
at async file:///home/farhan/parse-server-example/index.js:36:3 {

code: 'ERR_REQUIRE_ESM'
}
/home/farhan/parse-server-example/node_modules/parse-server/lib/ParseServer.js:146
require(path.resolve(process.cwd(), cloud));
^

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/farhan/parse-server-example/cloud/main.js from /home/farhan/parse-server-example/node_modules/parse-server/lib/ParseServer.js not supported.
main.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename main.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /home/farhan/parse-server-example/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

at ParseServer.start (/home/farhan/parse-server-example/node_modules/parse-server/lib/ParseServer.js:146:13)
at async file:///home/farhan/parse-server-example/index.js:36:3 {

code: 'ERR_REQUIRE_ESM'
}

Copy link

Thanks for opening this issue!

@dplewis
Copy link
Member

dplewis commented Jul 10, 2024

@mtrezza Looks like cloud folder is dynamically imported

https://github.com/parse-community/parse-server/blob/alpha/src/ParseServer.js#L187

@mtrezza
Copy link
Member

mtrezza commented Jul 11, 2024

Is this only an example repo issue or a parse server issue?

@dplewis
Copy link
Member

dplewis commented Jul 17, 2024

@mtrezza You reopened an issue for this parse-community/parse-server#7559

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants