You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Serverless Framework部署报错:functions[].entrypoint已存在定义

AWS Serverless Framework部署TypeScript应用报错问题

错误信息

"Property 'functions[].entrypoint' already have a definition - this property might have already been defined by the Serverless framework or one other plugin"

已搜索该错误信息但未找到有效解决方案。

尝试过的操作

  • 将所有函数配置统一写在serverless.yml文件中
  • 添加了以下webpack配置:
const path = require('path');
const slsw = require('serverless-webpack');
const nodeExternals = require('webpack-node-externals');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

module.exports = {
  context: __dirname,
  mode: slsw.lib.webpack.isLocal ? 'development' : 'production',
  entry: slsw.lib.entries,
  devtool: slsw.lib.webpack.isLocal ? 'eval-cheap-module-source-map' : 'source-map',
  resolve: {
    extensions: ['.mjs', '.json', '.ts'],
    symlinks: false,
    cacheWithContext: false,
    alias: {
      '@types': path.resolve(__dirname, "src", "@types"),
      libs: path.resolve(__dirname, "src", "libs"),
      packages: path.resolve(__dirname, "src", "packages")
    }
  },
  output: {
    libraryTarget: 'commonjs',
    path: path.join(__dirname, '.webpack'),
    filename: '[name].js',
  },
  optimization: {
    concatenateModules: false,
    minimize: false,
  },
  target: 'node',
  externals: [nodeExternals()],
  module: {
    rules: [
      // all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
      {
        test: /\.(tsx?)$/,
        loader: 'ts-loader',
        exclude: [
          [
            path.resolve(__dirname, 'node_modules'),
            path.resolve(__dirname, '.serverless'),
            path.resolve(__dirname, '.webpack'),
          ],
        ],
        options: {
          transpileOnly: true,
          experimentalWatchApi: true,
        },
      },
    ],
  },
  plugins: [
    new ForkTsCheckerWebpackPlugin({
      eslint: {
        enabled: true,
        files: './src/**/*.ts',
      },
      // eslintOptions: {
      //   cache: true
      // }
    })
  ],
};

临时解决办法

目前尚未解决原问题,但通过使用Serverless官方TypeScript模板(AWS Node REST API TypeScript)继续项目,已成功完成部署。

内容的提问来源于stack exchange,提问作者Luis Gustavo Barcelos

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 13:07:52