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
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.
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.
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 .
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:
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.
© 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.
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With