gpt4 book ai didi

webpack - serverless-webpack 找不到模块 './node/NodeTemplatePlugin'

转载 作者:行者123 更新时间:2023-12-02 04:34:33 26 4
gpt4 key购买 nike

我正在尝试使用 serverless-webpack plugin ,虽然单独运行 webpack 工作正常,但尝试运行 serverless-webpack 失败并显示 Cannot find module './node/NodeTemplatePlugin'

我的serverless.yml文件如下:

service: kamehameha

provider:
name: aws
runtime: nodejs6.10

functions:
getDeltas:
handler: bundle.getDeltas

plugins:
- serverless-webpack

我的 webpack 配置如下:

let path = require("path")
let webpack = require("webpack")
let nodeExternals = require("webpack-node-externals")

module.exports = {
entry: "./src/index.re",
target: "node",
node: {
__dirname: true,
},
externals: [nodeExternals()],
output: {
path: __dirname,
filename: "bundle.js",
},
module: {
loaders: [
{
test: /\.re$/,
loader: "bs-loader",
},
],
},
resolve: {
extensions: [".re", ".ml", ".js"],
},
}

webpack单独编译原因文件到bundle.js,然而serverless-webpack运行时出现上述错误。

我正在尝试使用该插件,因为单独编译和部署会导致找不到处理程序的 lambda 错误。

我试过删除全局 webpack 安装并仅使用本地 webpack 安装,以及无服务器。有没有人遇到过类似的情况?

谢谢!

最佳答案

确保在 serverless.ymlcustom 部分的 webpack 配置中设置了 includeModules: true

来自 serverless-webpack文档:

custom:
webpack:
webpackConfig: 'webpack.config.js' # Name of webpack configuration file
includeModules: false # Node modules configuration for packaging
packager: 'npm' # Packager that will be used to package your external modules
excludeFiles: src/**/*.test.js # Provide a glob for files to ignore

关于webpack - serverless-webpack 找不到模块 './node/NodeTemplatePlugin',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44812204/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com