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

srvpro使用node启动问题 #56

Open
Kkyoyo opened this issue Feb 23, 2022 · 6 comments
Open

srvpro使用node启动问题 #56

Kkyoyo opened this issue Feb 23, 2022 · 6 comments
Assignees

Comments

@Kkyoyo
Copy link

Kkyoyo commented Feb 23, 2022

我使用node去启动ygopro-server时,错误如下:

`/root/ygo2/ygopro-server/ygopro-server.js:77
  loadJSON = require('load-json-file').sync;
             ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /root/ygo2/ygopro-server/node_modules/[email protected]@load-json-file/index.js from /root/ygo2/ygopro-server/ygopro-server.js not supported.
Instead change the require of index.js in /root/ygo2/ygopro-server/ygopro-server.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/root/ygo2/ygopro-server/ygopro-server.js:77:14)
    at Object.<anonymous> (/root/ygo2/ygopro-server/ygopro-server.js:5277:4) {
  code: 'ERR_REQUIRE_ESM'
}`

根据查询是试用了load-json-file使用了es6语法而项目不支持,不知道如何解决

@mercury233
Copy link
Contributor

@Kkyoyo
Copy link
Author

Kkyoyo commented Feb 23, 2022

感谢回复,解决了那个问题以后还有这个提示
`root@iZuf646y583ci0k754bvztZ:~/ygo2/ygopro-server# node ygopro-server.js
file:///root/ygo2/ygopro-server/ygopro-server.js:6
net = require('net');
^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/root/ygo2/ygopro-server/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///root/ygo2/ygopro-server/ygopro-server.js:6:3
at file:///root/ygo2/ygopro-server/ygopro-server.js:5277:4
at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:337:24)
at async loadESM (node:internal/process/esm_loader:88:5)
at async handleMainPromise (node:internal/modules/run_main:61:12)`
系统是ubuntu20

@mercury233
Copy link
Contributor

原本的 package.json 里没有 "type": "module",不知道你是怎么添加的,删掉应该就好了

@purerosefallen
Copy link
Member

你的 node 运行环境是?

@Kkyoyo
Copy link
Author

Kkyoyo commented Feb 23, 2022

原本的 package.json 里没有 "type": "module",不知道你是怎么添加的,删掉应该就好了

感谢回复,已经可以了,"type": "module"是因为之前那个load-json-file的问题添加的,现在去掉就行了

@Kkyoyo
Copy link
Author

Kkyoyo commented Feb 23, 2022

你的 node 运行环境是?

是16.14.0,问题已经解决了,感谢大佬们

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

No branches or pull requests

3 participants