Reputation: 221
I am running my nodejs code and also installed serverless(npm i -g serverless) but while running it with the command sls offline start --CacheInvalidations
I am getting error as:-
Serverless 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
Your Environment Information ---------------------------
Operating System: linux
Node Version: 12.18.2
Framework Version: 1.79.0
Plugin Version: 3.7.1
SDK Version: 2.3.1
Components Version: 2.34.6
Upvotes: 20
Views: 39744
Reputation: 21
There is another way to try with
npx serverless plugin install --name serverless-offline
this is for install serverless-offline plugin. you also can view available plugin names bu
npx sls plugin list
Upvotes: 2
Reputation: 93
Try in your project with the npx
prefix. So npx sls offline
or npx serverless offline
. It worked for me.
Upvotes: 0
Reputation: 168
I was facing the same issue while setting up serverless.yml with nodejs and running it on local. Two steps resolved the problem.
npm i -g serverless-offline
plugins:
- serverless-offline
Upvotes: 5
Reputation: 643
plugins:
# Needed to run & debug locally
- serverless-offline
Upvotes: 0
Reputation: 33
First, you have to install serverless offline globally.
npm i -g serverless-offline
Next, you should check a serverless.yml file. Otherwise, you must create a serverless.yml file.
service: your-service-name
app: app-name
provider:
name: aws
runtime: nodejs10.x
timeout: 60
memorySize: 128
deploymentBucket: bucket-name
# you can overwrite defaults here
stage: prod
region: your-aws-region
functions:
your-function-name:
handler: handler.dispatch
memorySize: 128
timeout: 60
events:
#- http: POST /hello
- http: 'ANY {proxy+}'
plugins:
- serverless-offline
- serverless-aws-alias
Upvotes: 0
Reputation: 1257
Installing the dependency with yarn you can run the command typing the following:
Install:
yarn add serverless-offline -D
Run:
yarn serverless offline start
Upvotes: 2
Reputation: 490
Not sure if you solved this issue but I was having the same problem, for me it was a silly error, the indentation of the YML file was wrong, after fixing the indentation it started to work just fine
Upvotes: 0
Reputation: 1
You have to install the package (or locally in your project or globally). I do recommend install globally.
npm i -g serverless-offline
or
yarn global add serverless-offline
Inside your serverless.yml file, add in the plugins session the following code:
plugins:
It will sove your problem
Upvotes: 0
Reputation: 658
You need to install the serverless-offline
plugin using npm in order to use sls offline
command.
Just simply run:
npm i -g serverless-offline
to install globally on your device or
npm i serverless-offline --save-dev
to install it as a development dependency in the active project. and then add this configuration to your serverless template:
plugins:
- serverless-offline
For more information on serverless-offline
plugin take a look at serverless official documents:
Serverless Offline | Emulate AWS λ and API Gateway locally when developing your Serverless project
Upvotes: 19