Serverless plugin not found even though it is installed and listed

Hi,

I’m trying to run sls deploy and I’m getting the following error:

  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
     Forums:        forum.serverless.com
     Chat:          gitter.im/serverless/serverless
 
  Your Environment Information -----------------------------
     OS:                     linux
     Node Version:           5.3.0
     Serverless Version:     1.19.0

As the error says I have checked to make sure the plugin is installed. I’ve deleted and re-run npm install with

`"serverless-python-requirements": "^2.5.0",`

listed in my package.json file.

My serverless.yml file includes

plugins:
  - serverless-python-requirements


provider:
  name: aws
  runtime: python3.6

My co-worker is able to run sls deploy when he pulls my most recent code. Am I missing something in my setup?

Hey @Cael6, in your service directory, can you run npm list | grep serverless-python-requirements?

If it’s installed correctly, it should look something like this:

$ npm list | grep serverless-python-requirements
└─┬ serverless-python-requirements@2.5.0

If it’s not installed, you’ll get a bunch of output about missing packages.

If that doesn’t work, we can try something else.

That is exactly what I got:

$ npm list | grep serverless-python-requirements
├─┬ serverless-python-requirements@2.5.0

Hmm. In your service directory, can you drop into a Node REPL and see if you can load the plugin?

Run the following commands:

$ node
> require('serverless-python-requirements');
[Function: ServerlessPythonRequirements] # <--- Should see this if successful

Error: Cannot find module 'serverless-python-requirements' # <--- Will see this if unsuccessful

Here’s what I got:

$ node
> require('serverless-python-requirements');
/path/to/node_modules/serverless-python-requirements/index.js:8
const {spawnSync} = require('child_process');
      ^
SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:405:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at repl:1:1
    at REPLServer.defaultEval (repl.js:252:27)
    at bound (domain.js:287:14)

It looks like I needed to be running node v6+. Thanks for your help @alexdebrie1

I have the same problem with the serverless-client-s3 plugin.

$ npm list  | grep serverless-client-s3
└─┬ serverless-client-s3@2.0.0

$ node
> require('serverless-client-s3');
[Function]

 $ sls
 
  Serverless Error ---------------------------------------
 
  Serverless plugin "serverless-client-s3" not found. Make sure it's installed and listed in the "plugins" section of your serverless config file.
 [...]     
  Your Environment Information -----------------------------
     OS:                     linux
     Node Version:           6.11.0
     Serverless Version:     1.20.2

I have used both npm and yarn. Could this be the problem?

@paolini If you turn on debug mode, it will show more context around why the plugin isn’t loading.

$ SLS_DEBUG=* sls

That should throw the actual error for the plugin.

> SLS_DEBUG=* sls
 
  Type Error ---------------------------------------------
 
  S.getServerlessPath is not a function
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Stack Trace --------------------------------------------
 
TypeError: S.getServerlessPath is not a function
    at new module.exports (/Users/paolini/notes/node_modules/serverless-client-s3/index.js:5:30)
    at PluginManager.addPlugin (/Users/paolini/.config/yarn/global/node_modules/serverless/lib/classes/PluginManager.js:34:28)
    at plugins.forEach (/Users/paolini/.config/yarn/global/node_modules/serverless/lib/classes/PluginManager.js:72:14)
    at Array.forEach (native)
    at PluginManager.loadPlugins (/Users/paolini/.config/yarn/global/node_modules/serverless/lib/classes/PluginManager.js:68:13)
    at PluginManager.loadServicePlugins (/Users/paolini/.config/yarn/global/node_modules/serverless/lib/classes/PluginManager.js:114:10)
    at PluginManager.loadAllPlugins (/Users/paolini/.config/yarn/global/node_modules/serverless/lib/classes/PluginManager.js:64:10)
    at service.load.then (/Users/paolini/.config/yarn/global/node_modules/serverless/lib/Serverless.js:64:28)
From previous event:
    at runCallback (timers.js:651:20)
    at tryOnImmediate (timers.js:624:5)
    at processImmediate [as _immediateCallback] (timers.js:596:5)
From previous event:
    at __dirname (/Users/paolini/.config/yarn/global/node_modules/serverless/bin/serverless:25:46)
    at Object.<anonymous> (/Users/paolini/.config/yarn/global/node_modules/serverless/bin/serverless:43:4)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:418:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:533:3

@paolini Looks like there was a compatibility issue with pre-1.0 versions of the Framework and 1.0+ versions. That was fixed in a PR, but a new release wasn’t published to NPM because the credentials are lost – see here.

Fortunately, someone forked the project into serverless-finch which has the latest updates. :tada: I would recommend using that instead of serverless-client-s3.

1 Like

I’ve got the same problem

> require('serverless-python-requirements')
[class ServerlessPythonRequirements]

Why is this?
I setting NODE_PATH as /.nvm/versions/node/v16.14.0/lib/node_modules and install as nvm i -g serverless-python-requirements.

but continue

  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:          darwin
     Node Version:              16.14.0
     Framework Version:         1.61.2
     Plugin Version:            3.8.4
     SDK Version:               2.3.2
     Components Core Version:   1.1.2
     Components CLI Version:    1.6.0

By creating a separate package.json in the Python project, the plugin installation and operation works well.
But since it is inefficient to install each package.json for many serverless, I want to use the global module, but is there any way?