Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serverless command "offline" not found

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
like image 208
Nikhil Srivastava Avatar asked Aug 20 '20 14:08

Nikhil Srivastava


People also ask

How do I start serverless offline?

Steps: Since you already know the basics of Serverless Framework, you must have installed the framework. Next, install the package serverless-offline from npm. Add this installed plugin to your serverless project.

Is serverless offline?

The serverless offline plugin for Node. js allows you to emulate AWS Lambda and API Gateway on a local machine. By using the serverless offline plugin, you can test your serverless applications without deploying them every time you make a change. This makes for a faster and better developer experience.

How do I change serverless offline ports?

The workaround for this is to keep serverless-offline-local plugin enabled in only one service (if you have two or more). Example, In my-service-1 you keep all dynamodb config in serverless. yaml file and start this service with default port: sls offline start --migrate true .

How to use SLS offline command in serverless template?

You need to install the serverless-offline plugin using npm in order to use sls offline command. to install it as a development dependency in the active project. and then add this configuration to your serverless template: For more information on serverless-offline plugin take a look at serverless official documents:

How to run serverless offline using NPM?

Since you already know the basics of Serverless Framework, you must have installed the framework. Next, install the package serverless-offline from npm. 2. Add this installed plugin to your serverless project. 3. Run serverless offline using command: 4.

What is the serverless offline plugin?

© 2022 Fauna, Inc. All Rights Reserved. The serverless offline plugin for Node.js allows you to emulate AWS Lambda and API Gateway on a local machine. By using the serverless offline plugin, you can test your serverless applications without deploying them every time you make a change. This makes for a faster and better developer experience.

How to install a serverless-offline package with yarn?

Install serverless-offline package globally. Add the same package under the plugin key of your serverless.yml file. Installing the dependency with yarn you can run the command typing the following: You have to install the package (or locally in your project or globally). I do recommend install globally.


Video Answer


2 Answers

I was facing the same issue while setting up serverless.yml with nodejs and running it on local. Two steps resolved the problem.

  1. Install serverless-offline package globally.

npm i -g serverless-offline

  1. Add the same package under the plugin key of your serverless.yml file.

plugins:
- serverless-offline

like image 26
Rajat Upadhyay Avatar answered Oct 20 '22 02:10

Rajat Upadhyay


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

Serverless Offline NPM

like image 171
Mohammad Moallemi Avatar answered Oct 20 '22 02:10

Mohammad Moallemi