eggjs / egg

🥚 Born to build better enterprise frameworks and apps with Node.js & Koa

Home Page:https://eggjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

我在 package.json 里加入了 "type": "module", 引起错误

15844229646 opened this issue · comments

请详细告知你的新点子(Nice Ideas):

我在 package.json 里加入了 "type": "module",

完整的配置文件
{
"name": "egg-example",
"version": "1.0.0",
"description": "hackernews showcase using typescript && egg",
"private": true,
"type": "module",
"egg": {
"typescript": true
},
"scripts": {
"start": "egg-scripts start",
"dev": "egg-bin dev",
"debug": "egg-bin debug",
"test-local": "egg-bin test",
"test": "npm run lint -- --fix && npm run test-local",
"cov": "egg-bin cov",
"tsc": "tsc -p tsconfig.json",
"ci": "npm run lint && npm run cov && npm run tsc",
"lint": "eslint .",
"clean": "tsc -b --clean",
"manifest": "node ./bungieCmd/manifest.js",
"module": "node ./bungieCmd/module.js"
},
"dependencies": {
"axios": "^1.3.4",
"egg": "^3.11.0",
"egg-mongoose": "^3.3.1",
"egg-scripts": "^2.17.0",
"egg-view-nunjucks": "^2.3.0",
"moment": "^2.22.0",
"mongoose": "^7.0.3",
"nodemailer": "^6.9.1"
},
"devDependencies": {
"@eggjs/tsconfig": "^1.1.0",
"@types/cheerio": "^0.22.1",
"@types/mocha": "^10.0.1",
"cheerio": "^1.0.0-rc.2",
"egg-bin": "^5.9.0",
"egg-mock": "^5.5.0",
"eslint": "^8.31.0",
"eslint-config-egg": "^12.1.0",
"typescript": "^4.9.4"
},
"engines": {
"node": ">=16.0.0"
}
}

结果报错

E:\work\egg-example\node_modules\egg-bin\lib\start-cluster {"typescript":true,"tsconfigPaths":true,"tsconfig-paths":true,"tscompiler":"E:\work\egg-example\node_modules\ts-node\register\index.js","eggTsHelper":"E:\work\egg-example\node_modules\egg-ts-helper\register.js","workers":1,"baseDir":"E:\work\egg-example","framework":"E:\work\egg-example\node_modules\egg"} exit with code 1
at ChildProcess. (E:\work\egg-example\node_modules\common-bin\lib\helper.js:56:21)

解决
将 "type": "module", 删除即可运行 dev

是 egg 不支持 module 模式吗

egg 目前只支持 cjs,还不支持 esm。