'Serverless plugin "serverless-offline" not found. Make sure it's installed and listed in the "plugins" section of your serverless config file

When I deploy my SLS project, I get the following error:

Serverless plugin "serverless-offline" not found. Make sure it's installed and listed in the "plugins" section of your serverless config file

But I did install the plugin serverless-offline correctly, please can someone help me fix it.

Here is my serverless.yml file:

   service: email-sender

    provider:
      name: aws
      runtime: nodejs4.3

    functions:
      send:
        handler: handler.send
        events:
          - http:
              path: submissions
              method: post
              response:
                headers:
                  Content-Type: "text/json"
              cors:
                origins:
                  - '*'
    package:
      exclude:
        - node_modules/**
      include:
        - node_modules/serverless-offline/**

    plugins:
      - serverless-offline


Solution 1:[1]

Serverless offline is a plugin to run only on your development machine, not in production.

To enable it add the following to serverless.yml:

    plugins:
      - serverless-offline

and remove the following lines

      include:
        - node_modules/serverless-offline/**

also check your package.json and make sure it is a devDependencies.

Solution 2:[2]

Please ensure that serverless-offline package is included in dev dependencies, if not then add it

"serverless-offline": "3.20.2"

and run,

npm install --save-dev

This solved my issue.

Solution 3:[3]

To resolve this error while running an automated CI pipeline or locally, try the following:

- npm config set prefix /usr/local
- npm install -g serverless
- npm install serverless-offline -g
- npm install --save-dev
- serverless deploy --stage production --verbose

Also, check your package.json and ensure the serverless-offline package is included in devDependencies.

This fixed the issue for me.

Happy Serverless!

Solution 4:[4]

I encountered a similar issue on bitbucket pipelines. I fixed the issue (after many trials and errors) by updating "script" section of your bitbucket-pipelines.yml file with the following:

          script:
            - npm install -g npm
            - npm install --save-dev
            - pipe: atlassian/serverless-deploy:1.1.1
              variables:
                AWS_ACCESS_KEY_ID: $KEY_DEFINED_ON_BITBUCKET
                AWS_SECRET_ACCESS_KEY: $KEY_DEFINED_ON_BITBUCKET

Also, check your package.json and ensure the serverless-offline package and any other plugins in the serverless.yml file are included in devDependencies.

Big thanks to K Manoj Kumar's answer for giving me a clue.

If you are not using bitbucket pipeline, I feel replacing the "pipe" section on the bitbucket-pipelines.yml file with something like npm run deploy and adding "deploy": "serverless deploy" to the "scripts" section on your package.json will work.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Max
Solution 2 Sksaif Uddin
Solution 3 K Manoj Kumar
Solution 4 Peter Umoren