提问人:BBB 提问时间:9/7/2023 最后编辑:BBB 更新时间:9/8/2023 访问量:85
通过 nodejs fastify 启动 webpack dev server 时出错
Error while starting webpack dev server over nodejs fastify
问:
命令:
"build": "webpack --config ./webpack.development.js"
"start": "fastify start -l debug --options dist/bundle.js",
错误:
AvvioError \[Error\]: Plugin must be a function or a promise. Received: 'object'
at assertPlugin (C:\\Local\\Work\\Digital\\yyy\\DEV\\GIT\\yyy-webpack\\node_modules\\avvio\\boot.js:207:11)
at Boot.\_addPlugin (C:\\Local\\Work\\Digital\\yyy\\DEV\\GIT\\yyy-webpack\\node_modules\\avvio\\boot.js:240:12)
at Boot.use (C:\\Local\\Work\\Digital\\yyy\\DEV\\GIT\\yyy-webpack\\node_modules\\avvio\\boot.js:216:25)
at Object.server.\<computed\> \[as register\] (C:\\Local\\Work\\Digital\\yyy\\DEV\\GIT\\yyy-webpack\\node_modules\\avvio\\boot.js:40:14)
at runFastify (C:\\Local\\Work\\Digital\\yyy\\DEV\\GIT\\yyy-webpack\\node_modules\\fastify-cli\\start.js:149:17) {
code: 'AVV_ERR_PLUGIN_NOT_VALID'
}
如何调试 fastify 自动加载插件?
尝试调试设置fastify start命令-l选项不起作用。 期望使用一个 bundle.js 文件成功启动应用程序并提供 GraphQL Apollo Playground
更新:./webpack.development.js
const merge = require('webpack-merge');
const nodeExternals = require('webpack-node-externals');
const path = require('path');
const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const common = require('./webpack.common.js');
module.exports = merge.smart(common, {
devtool: 'inline-source-map',
entry: ['webpack/hot/poll?1000', path.join(__dirname, 'src/app.ts')],
externals: [
nodeExternals({
allowlist: ['webpack/hot/poll?1000']
})
],
devServer: {
port: 8080,
},
mode: 'development',
plugins: [new CleanWebpackPlugin(), new webpack.HotModuleReplacementPlugin()]
});
webpack.common.js
const path = require('path');
module.exports = {
module: {
rules: [
{
exclude: [path.resolve(__dirname, 'node_modules')],
test: /\.ts$/,
use: 'ts-loader'
}
]
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
resolve: {
extensions: ['.ts', '.js']
},
target: 'node'
};
紧固自动加载:
await fastify.register(AutoLoad, {
dir: join(__dirname, 'plugins'),
options: opts,
})
答: 暂无答案
评论
./webpack.development.js"