sst.dev
sst.dev copied to clipboard
Serverless plugin "serverless-offline" not found.
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 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!
@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
Thank you both. All good with latest repo.
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!
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.
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

Does your package.json mention "serverless-offline" ? (At least as devDependencies)
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.
Ok, so you juste have to type into a terminal : npm install serverless-offline --save-dev
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.
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.
Same here actually, and i do have it under my plugins
in my serverless.yml
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