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

时间:2017-06-28 20:42:17

标签: webpack serverless-framework

我尝试使用serverless-webpack plugin,而单独运行webpack工作正常,尝试运行无服务器的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安装,只使用本地安装,以及无服务器。有没有人遇到过类似的东西?

谢谢!

1 个答案:

答案 0 :(得分:0)

请确保在includeModules: true的{​​{1}}部分的webpack配置中设置了custom

摘自serverless-webpack文档:

serverless.yml