Error [ERR_REQUIRE_ESM]: require() of ES Module
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- javascript, node.js
- 领域
- backend
调研方向
首先使用 node index.js 重现错误,然后检查 package.json、cloud/main.js、index.js:36 以及 node_modules/parse-server/lib/ParseServer.js:146 中的 require 调用。将模块设置与报告的 ERR_REQUIRE_ESM 指南进行比较,并验证示例能够在没有该错误的情况下启动。
由索引模型根据 Issue 内容生成。
描述
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'
}
- 主要语言
- JavaScript
- 星标
- 1.9k
- 派生
- 5.3k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
parse-community/parse-server-example 的其他 Issue
-
typo error in README.md file可能已有人在做 @Syed25794 于 1228 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 65/100
parse-community/parse-server-example#436 · 1 条评论 ·
-
type:bug
难度 3/5 1-2 天 新手友好度 30/100
parse-community/parse-server-example#432 · 17 条评论 ·
-
type:bug
难度 3/5 1-2 天 新手友好度 35/100
parse-community/parse-server-example#431 · 3 条评论 ·
-
type:bug
难度 3/5 1-2 天 新手友好度 25/100
parse-community/parse-server-example#420 · 1 条评论 ·
-
type:docs
难度 2/5 1-3 小时 新手友好度 35/100
parse-community/parse-server-example#404 · 4 条评论 · 1 个 reaction ·
查看 parse-community/parse-server-example 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
szTheory/exifcleaner#383 ·
维护者通常 1 天内回复
-
Frontend good first issue P2-medium UI UX
难度 2/5 1-3 小时 新手友好度 75/100
Deepak3699/Ai_Mentor#179 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
python-visualization/folium#2293 · 1 条评论 ·
维护者通常 1 天内回复
-
good first issue type: bug
难度 1/5 1 小时以内 新手友好度 88/100
medusajs/medusa#17127 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
keyxmakerx/Chronicle#1061 ·
维护者通常 1 天内回复