I am trying to follow along with the exercises in the Serverless Stack PDF. So far it is a really great read and I am learning a lot. I am currently at the create note part (On the front end). Currently when a user tries to create a note they receive a 503 status code. When I looked in the logs on cloud watch I was given an error that said 'unable to import module create'. After seeing this issue I decided to run a test in the AWS console on the create lambda. When I did this I received this error "cannot find module 'runtime/regenerator'". From here I decided to try and update all the npm packages to their latest version and change babel config accordingly. After testing again I get the same error "Cannot find module '@babel/runtime/regenerator'''. Local function calls work but, not once it is on the actual Lambda. I have copied and pasted some files below. Thank you in advance for any help with this issue.
module.exports = {
entry: slsw.lib.entries,
target: "node",
// Generate sourcemaps for proper error messages
devtool: 'source-map',
// Since 'aws-sdk' is not compatible with webpack,
// we exclude all node dependencies
externals: [nodeExternals()],
mode: slsw.lib.webpack.isLocal ? "development" : "production",
optimization: {
// We do not want to minimize our code.
minimize: false
},
performance: {
// Turn off size warnings for entry points
hints: false
},
// Run babel on all .js files and skip those in node_modules
module: {
rules: [
{
test: /.js$/,
loader: "babel-loader",
include: __dirname,
exclude: /node_modules/
}
]
}
};
`
I am trying to follow along with the exercises in the Serverless Stack PDF. So far it is a really great read and I am learning a lot. I am currently at the create note part (On the front end). Currently when a user tries to create a note they receive a 503 status code. When I looked in the logs on cloud watch I was given an error that said 'unable to import module create'. After seeing this issue I decided to run a test in the AWS console on the create lambda. When I did this I received this error "cannot find module 'runtime/regenerator'". From here I decided to try and update all the npm packages to their latest version and change babel config accordingly. After testing again I get the same error "Cannot find module '@babel/runtime/regenerator'''. Local function calls work but, not once it is on the actual Lambda. I have copied and pasted some files below. Thank you in advance for any help with this issue.
package.json
{ "name": "notes-app-api", "version": "1.1.0", "description": "A Node.js starter for the Serverless Framework with async/await and unit test support", "main": "handler.js", "scripts": { "test": "jest" }, "author": "", "license": "MIT", "repository": { "type": "git", "url": "https://github.com/AnomalyInnovations/serverless-nodejs-starter.git" }, "devDependencies": { "@babel/core": "^7.4.5", "@babel/plugin-transform-runtime": "^7.4.4", "@babel/preset-env": "^7.4.5", "aws-sdk": "^2.485.0", "babel-loader": "^8.0.6", "babel-plugin-source-map-support": "^2.0.1", "jest": "^21.2.1", "serverless": "^1.46.1", "serverless-offline": "^5.3.3", "serverless-webpack": "^5.3.1", "webpack": "^4.35.0", "webpack-node-externals": "^1.7.2" }, "dependencies": { "@babel/runtime": "^7.4.5", "ajv": "^6.10.0", "source-map-support": "^0.5.12", "uuid": "^3.3.2" } }
babelrc.
{ "plugins": ["babel-plugin-source-map-support", "@babel/plugin-transform-runtime"], "presets": [ ["@babel/preset-env"], ] }
webpack.config.js
` const slsw = require("serverless-webpack"); const nodeExternals = require("webpack-node-externals");
module.exports = { entry: slsw.lib.entries, target: "node", // Generate sourcemaps for proper error messages devtool: 'source-map', // Since 'aws-sdk' is not compatible with webpack, // we exclude all node dependencies externals: [nodeExternals()], mode: slsw.lib.webpack.isLocal ? "development" : "production", optimization: { // We do not want to minimize our code. minimize: false }, performance: { // Turn off size warnings for entry points hints: false }, // Run babel on all .js files and skip those in node_modules module: { rules: [ { test: /.js$/, loader: "babel-loader", include: __dirname, exclude: /node_modules/ } ] } }; `