question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error upon deployment

See original GitHub issue

Error in the logs

module initialization error
TypeError

sls version: 1.32.0 serverless-plugin-warmup@3.6.1-rc.1

This was working before i upgraded to babel7

service: adcentre-invoices
frameworkVersion: ">=1.2.0 <2.0.0"

plugins:
  - serverless-webpack # Use serverless-webpack plugin to transpile ES6/ES7
  - serverless-offline-ssm
  - serverless-offline
  - serverless-apigw-binary
  - serverless-domain-manager
  - serverless-plugin-warmup

provider:
  name: aws
  runtime: nodejs8.10
  region: ap-southeast-2
  warmup:
    folderName: "_warmup" # Name of the folder created for the generated warmup
    cleanFolder: true
    memorySize: 256
    name: ${self:custom.warmupLambdaName}
    schedule: "rate(5 minutes)" # Run WarmUP every 5 minutes
    timeout: 20
    prewarm: true # Run WarmUp immediately after a deployment
  apigwBinary:
    types: #list of mime-types
      # - 'image/jpeg'
      # - 'text/html'
      - "application/pdf"
  webpack:
    webpackConfig: ./webpack.config.js
    includeModules: true
    packager: "npm"
    package:
      individually: true #Webpack compiles and optimizes each function individually,
      # removing unnecessary imports and reducing code sizes significantly

webpack.config.js

const slsw = require("serverless-webpack");
const nodeExternals = require("webpack-node-externals");
const Dotenv = require("dotenv-webpack");

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 no not want to minimize our code.
    minimize: false
  },
  performance: {
    // Turn off size warnings for entry points
    hints: false
  },
  plugins: [new Dotenv()],
  // Run babel on all .js files and skip those in node_modules
  module: {
    rules: [
      {
        test: /\.js$/,
        include: __dirname,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader",
          options: {
            presets: ["@babel/preset-env"]
          }
        }
      }
    ]
  }
};

devDep

  "devDependencies": {
    "@babel/core": "^7.1.0",
    "@babel/plugin-transform-runtime": "^7.1.0",
    "@babel/preset-env": "^7.0.0",
    "@babel/register": "^7.0.0",
    "@pact-foundation/pact": "5.9.1",
    "@pact-foundation/pact-node": "^6.19.4",
    "artillery": "^1.6.0-22",
    "aws-sdk": "2.315.0",
    "babel-loader": "^8.0.0",
    "babel-plugin-istanbul": "5.0.1",
    "babel-plugin-source-map-support": "2.0.1",
    "body-parser": "^1.18.3",
    "chai": "4.1.2",
    "commitizen": "^2.10.1",
    "cors": "^2.8.4",
    "cross-env": "5.2.0",
    "cz-conventional-changelog": "^2.1.0",
    "dotenv": "^6.0.0",
    "eslint": "^5.6.0",
    "eslint-config-airbnb-base": "^13.1.0",
    "eslint-config-prettier": "^3.0.1",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-prettier": "^2.6.2",
    "express": "^4.16.3",
    "helmet": "^3.13.0",
    "husky": "0.14.3",
    "lint-staged": "7.3.0",
    "mocha": "5.2.0",
    "mocha-lcov-reporter": "1.3.0",
    "nock": "^10.0.0",
    "nodemon": "^1.18.3",
    "npm-run-all": "^4.1.3",
    "nyc": "^13.0.1",
    "prettier": "1.14.3",
    "prettier-eslint": "^8.8.2",
    "renovate-config-seek": "^0.3.0",
    "rimraf": "2.6.2",
    "serverless": "^1.30.0",
    "serverless-apigw-binary": "^0.4.4",
    "serverless-domain-manager": "^2.6.0",
    "serverless-offline": "^3.25.9",
    "serverless-offline-ssm": "^1.1.0",
    "serverless-plugin-warmup": "^3.6.1-rc.1",
    "serverless-webpack": "5.2.0",
    "sinon": "^6.0.0",
    "sinon-chai": "^3.0.0",
    "webpack": "^4.19.1",
    "webpack-node-externals": "1.7.2"
  }

babelrc

{
  "comments": false,
  "plugins": ["source-map-support", "@babel/plugin-transform-runtime"],
  "presets": [
    [
      "@babel/preset-env",
      {
        "debug": false,
        "targets": {
          "node": "8.10"
        },
        "shippedProposals": true
      }
    ]
  ],
  "env": {
    "test": {
      "plugins": ["istanbul"]
    }
  }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
moonikercommented, Nov 21, 2019

@shavo007 what was the syntax you used to get this working with Express? Are you using serverless-http?

0reactions
juanjoDiazcommented, Oct 17, 2018

You can check #73 and #https://github.com/serverless-heaven/serverless-webpack/issues/454

The problem is that webpack tries to process functions that it shouldn’t and there seems to be no way to avoid it. I hope that we can work with the serverless-webpack maintainers to solve it.

As an alternative, for now, you can configure webpack so it can use commonjs (a.k.a. require).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot common Azure deployment errors
Error code Mitigation More inform... AccountNameInvalid Follow naming guidelines for storage accounts. Resolve erro... AccountPropertyCannotBeSet Check available storage account properties. storageAcco... AnotherOperationInProgress Wait for concurrent operation...
Read more >
Common Deployment Errors - DeployHQ
Common Deployment Errors · 452 Transfer aborted. No space left on device · 552 Disk full - please upload later · Automatic Deployments...
Read more >
Deployment errors | Apigee Edge
Any error that occurs during deployment of an API Proxy is called a Deployment error. Deployment of API proxies might fail due to...
Read more >
Shinyapps.io Returning an Error Upon Deployment
Hello,. I am attempting to deploy my dashboard to the web via Shinyapps.io. However, I am getting an error reading: "An error has...
Read more >
Azure Deployment Center generates error when deploying
Common.API.csproj : error MSB4242: at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.CachingWorkloadResolver.Resolve(String sdkReferenceName, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found