i'm trying to use serverless for the first time and although I think I have followed the docs etc I'm getting a weird error.
I have installed serverless and a few functions:
npm install -g serverless
npm install -g serverless-plugin-optimize
sls invoke local -f auth-handler -s local
Serverless: To ensure safe major version upgrades ensure "frameworkVersion" setting in service configuration (recommended setup: "frameworkVersion: ^2.1.1")
Serverless Error ---------------------------------------
ServerlessError: Serverless plugin "sls" not found. Make sure it's installed and listed in the "plugins" section of your serverless config file.
at C:\Users\cw\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:155:17
...
As you can see, I'm invoking sls and its running (I've exported SLS_DEBUG=* sls
to get some debug)
sls reports this as the environment:
Your Environment Information
---------------------------
Operating System: win32
Node Version: 12.18.4
Framework Version: 2.1.1
Plugin Version: 4.0.4
SDK Version: 2.3.2
Components Version: 3.1.3
my serverless.yml is:
service: serverless-optimize-example
provider:
name: aws
runtime: nodejs12.18
package:
individually: true
custom:
enable_optimize:
local: false
plugins:
- sls
- serverless-plugin-optimize
- serverless-offline
functions:
auth-handler:
handler: src/index.handler
optimize: ${self:custom.enable_optimize.${opt:stage,'dev'}, 'true'}
events:
- http:
path: /func1
method: get
What do I have to do to install sls, even though it looks like it is installed?
UPDATE I got it working, thanks @David Webster. It was this SO:
Fixing npm path in Windows 8 and 10
That finally solved it. For anybody else. There were 2 directories that needed to be added to my path:
%APPDATA%\npm
<path to nodejs>\node_modules\npm\bin e.g. C:\Program Files\nodejs\node_modules\npm\bin