我在使用aws serverless framework部署应用程序时遇到了一个问题。
错误消息:“Property 'functions[].entrypoint' already have a definition - this property might have already been defined by Serverless framework or one other plugin”
我已经搜索了错误消息,但没有找到任何可以帮助我的东西。我正在使用无服务器与TypeScript
this is the serverless.yml configuration and plugins that i'm using
And this is the function configuration file
有谁知道我该怎么解决这个问题吗?
我已经尝试使用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
// }
})
],
};
我还没有能够解决这个问题,但我能够通过使用TypeScript的无服务器模板继续我的项目。这样我就能完成部署。
如果需要,可以在this repo中找到几个模板
我用的是this one
1条答案
按热度按时间monwx1rj1#
我遇到了同样的问题,并通过在
serverless.yml
中使用serverless-webpack解决了它。我认为入口点首先在serverless-bundle
中定义,然后当它试图在serverless-webpack
中再次设置它时,它会产生错误