sst.dev icon indicating copy to clipboard operation
sst.dev copied to clipboard

Serverless plugin "serverless-offline" not found.

Open TinCharMan opened this issue 6 years ago • 13 comments

The latest serverless.yml in chapters add-a-create-note-api.md and add-support-for-es6-es7-javascript.md includes the serverless-offline plugin.

executing $ serverless invoke local --function create --path mocks/create-event.json generates the following error:

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

Executing $ npm install serverless-offline -g will install the plug in and resolve the issue.

Suggesting to add the following (line 46)

<img class="code-marker" src="/assets/s.png" />Install Serverless Offline globally.

bash $ npm install serverless-offline -g in setup-the-framework.md


The serverless-offline plugin emulates AWS Lambda and API Gateway on your local machine to speed up your development cycles. It starts an HTTP server that handles the request's lifecycle like APIG does and invokes your handlers.

TinCharMan avatar Apr 18 '18 12:04 TinCharMan

@TinCharMan In this page if you run a command as below, serverless-offline is already included in serverless.yml.

$ serverless install --url https://github.com/AnomalyInnovations/serverless-nodejs-starter --name notes-app-api

And I think you don't need to run npm install -g but npm install --save-dev or yarn add --save-dev because it's needed for the development(in devDependencies of package.json).

Happy serverless!

daenamkim avatar Apr 19 '18 01:04 daenamkim

@TinCharMan This might be because the latest change we made - https://github.com/AnomalyInnovations/serverless-stack-com/issues/223. Just make sure your project is up to date with the repo - https://github.com/AnomalyInnovations/serverless-stack-demo-api

jayair avatar Apr 20 '18 17:04 jayair

Thank you both. All good with latest repo.

TinCharMan avatar May 08 '18 00:05 TinCharMan

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!

kmanojkumar avatar Oct 18 '19 14:10 kmanojkumar

From a new serverless project, if everything is well installed (serverless-offline package...), check your serverless.yml.

You should have those lines :

plugins:
      - serverless-offline

Otherwise, this is why it does not work...

Regards.

aluzed avatar May 18 '20 11:05 aluzed

I have followed all instructions given in the site https://www.npmjs.com/package/serverless-offline and when I run sls offline i get below error --->

Serverless command "offline" not found. Did you mean "config"? Run "serverless help" for a list of all available commands.

Get Support -------------------------------------------- Docs: docs.serverless.com Bugs: github.com/serverless/serverless/issues Issues: forum.serverless.com

![yml file](https://user-images.githubusercontent.com/19429050/83171510-dceac980-a133-11ea-83d0-8c779e9f937f.JPG)

gouravbeyondBGCM avatar May 28 '20 17:05 gouravbeyondBGCM

Does your package.json mention "serverless-offline" ? (At least as devDependencies)

aluzed avatar May 28 '20 17:05 aluzed

no my package.json file doesnt have "serverless-offline" but yes package-lock.json file has it

and I already did this command "npm install serverless-offline --save-dev"

and I get below warning after running above command --> npm WARN [email protected] requires a peer of serverless@>=1.60.0 but none is installed. You must install peer dependencies yourself.

gouravbeyondBGCM avatar May 28 '20 18:05 gouravbeyondBGCM

Ok, so you juste have to type into a terminal : npm install serverless-offline --save-dev

aluzed avatar May 28 '20 18:05 aluzed

Ok, so you juste have to type into a terminal : npm install serverless-offline --save-dev

I think below warning message after running above commands creating problem , please comment

npm WARN [email protected] requires a peer of serverless@>=1.60.0 but none is installed. You must install peer dependencies yourself.

gouravbeyondBGCM avatar May 28 '20 20:05 gouravbeyondBGCM

I'm getting this error as well but I have installed it correctly and I have serverless-offline in my yml file. I even restarted my terminal session. Not sure what is going on.

chuckthepiranha avatar Mar 01 '21 17:03 chuckthepiranha

Same here actually, and i do have it under my plugins in my serverless.yml

mbast100 avatar Mar 03 '21 04:03 mbast100

Same issue here y have my serverless.yml start like this :

service: my-service
useDotenv: true
plugins:
  - serverless-offline
provider:
  name: aws
  runtime: nodejs14.x

my dependencies in package.json like this :

"dependencies": {
    "stripe": "^8.184.0"
  },
  "devDependencies": {
    "dotenv": "^10.0.0",
    "jest": "^27.3.1",
    "serverless-offline": "^8.2.0"
  }

and my .gitlab-ci.yml like this :

image: node:latest

stages:
  - test
  - deploy

test-integration:
  stage: test
  script:
    - export NODE_ENV=test
    - npm install
    - npm test
  artifacts:
    paths:
      - node_modules/
  environment: develop
  only:
    - develop

develop:
  stage: deploy
  before_script:
    - npm config set prefix /usr/local
    - npm install -g serverless
  script:
    - serverless deploy --stage develop --verbose
  environment: develop
  only:
    - develop

production:
  stage: deploy
  before_script:
    - npm config set prefix /usr/local
    - npm install -g serverless
  script:
    - serverless deploy --stage production --verbose

  environment: production
  only:
    - main

When I push on develop branch it work fine. My lambda is deployed and work fine as expected, but when I push on main branch I got this :

$ serverless deploy --stage production --verbose
 
 Serverless Error ----------------------------------------
 
  Serverless plugin "serverless-offline" not found. Make sure it's installed and listed in the "plugins" section of your serverless config file. Run "serverless plugin install -n serverless-offline" to install it.
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              17.0.1
     Framework Version:         2.64.1
     Plugin Version:            5.5.0
     SDK Version:               4.3.0
     Components Version:        3.17.1

MaximeLozach avatar Oct 28 '21 09:10 MaximeLozach