serverless: CLI can't work with existing project without node_modules

I have created a serverless project for python on AWS, which works fine… until I try to re-use the project directly after checkout. Any CLI command exits with the following error:

 sls help
 
 Serverless Error ---------------------------------------
 
  Serverless plugin "serverless-python-requirements" not found. Make sure it's installed and listed in the "plugins" section of your serverless config file.
 
  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.16.1
     Framework Version:         1.67.3 (standalone)
     Plugin Version:            3.6.6
     SDK Version:               2.3.0
     Components Version:        2.29.0

I installed Serverless with the method “Install as a standalone binary”. The node_modules folder wasn’t checked in, but package.json and package-lock.json are versioned with serverless.yml, and the plugin is also present in serverless.yml. Is this a bug, or am I missing some initialization step?

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 1
  • Comments: 17 (9 by maintainers)

Most upvoted comments

Would be better to just have a single command that installs all necessary plugins, as npm install or npm ci does.

I see, yes indeed there’s no method that will just install all plugin dependencies for an existing service. Interestingly it’s covered when you set up a new project via the serverless command and choose one of the existing templates.

I guess sls install could do it, if we make url option as optional WDYT @pgrzesik @mnapoli ?

The error you’re getting is because serverless is trying to find serverless-python-requirements in your node_modules but it isn’t there.

When you checkout, none of your dependencies are installed in the folder. The sls function isn’t responsible for installing your dependencies. You need to re-install them by running npm install once so that sls can use your dependencies.

This is standard for all NodeJS projects, when you clone or checkout a branch you should npm install so that the dependencies are downloaded into node_modules.