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
相关产品推荐
相关产品推荐

