egg icon indicating copy to clipboard operation
egg copied to clipboard

Can not find plugin bodyParser

Open steelan9199 opened this issue 3 years ago • 4 comments

在此输入你需要反馈的 Bug 具体信息(Bug in Detail):

我是win10, 复现问题步骤

  1. npm init egg --type=simple , 我是一路回车
  2. npm i
  3. config/plugin.js 文件内容如下
module.exports = {
  bodyParser: {
    enable: false,
  },
};

就只改了这一个地方, 其他地方都没改过, 然后就报错了 Error: Can not find plugin bodyParser in "E:\study\egg\egg-lesson03, E:\study\egg\egg-lesson03\node_modules\egg" at AgentWorkerLoader._resolvePluginPath (E:\study\egg\egg-lesson03\node_modules\egg-core\lib\loader\mixin\plugin.js:391:13)

可复现问题的仓库地址(Reproduction Repo)

https://github.com/steelan9199/egg-bug

Node 版本号:

v18.12.1

Eggjs 版本号:

"egg": "^3",

相关插件名称与版本号(PlugIn and Name):

"egg": "^3",

操作平台与版本号(Platform and Version):

win10

steelan9199 avatar Dec 09 '22 01:12 steelan9199

because there is not an egg plugin named bodyParser.

What is your original need and purpose?

atian25 avatar Dec 09 '22 01:12 atian25

这是egg官方文档 https://github.com/eggjs/egg/blob/11bbd852731b1583cae5a5d519baa20960c0521d/site/docs/basics/middleware.zh-CN.md

官方文档说, bodyParser是框架自带的中间件, 既然自带, 就不应该报错啊, 名字也是小驼峰 bodyParser

框架默认中间件 除了应用层加载中间件之外,框架自身和其他的插件也会加载许多中间件。所有的这些自带中间件的配置项都通过在配置中修改中间件同名配置项进行修改,例如框架自带的中间件中有一个 bodyParser 中间件(框架的加载器会将文件名中的各种分隔符都修改成驼峰形式的变量名),我们想要修改 bodyParser 的配置,只需要在 config/config.default.js 中编写

steelan9199 avatar Dec 09 '22 01:12 steelan9199

image

我们想要修改 bodyParser 的配置,只需要在 config/config.default.js 中编写

不是写着,它是一个中间件么?修改是 config,而不是 plugin,你改的是 config/plugin.js

atian25 avatar Dec 09 '22 01:12 atian25

ok thank you very much

steelan9199 avatar Dec 09 '22 01:12 steelan9199