dherault / serverless-offline

Emulate AWS λ and API Gateway locally when developing your Serverless project
MIT License
5.19k stars 795 forks source link

Serverless plugin "serverless-offline" not found #454

Closed ndeitch closed 6 years ago

ndeitch commented 6 years ago

Hey,

I'm trying to deploy a serverless service, with the command line:

serverless deploy --package dist-qa --stage qa -v

But I get the following error:

Serverless plugin "serverless-offline" not found. Make sure it's installed and listed in the "plugins" section of your serverless config file.

I've a project in serverless 1.28.0

Here is my devDependencies from package.json:

"devDependencies": {
    "chai": "^4.1.2",
    "eslint": "^5.1.0",
    "mocha": "^5.2.0",
    "nyc": "^12.0.2",
    "serverless-offline": "^3.25.6"
  },
"dependencies": {
  "aws-sdk": "^2.272.1",
  "moment": "^2.22.2"
}

Here is my serverless.yml:

service: hello

package:
  exclude:
    - test/**
    - dist-*/**

plugins:
  - serverless-offline

provider:
  name: aws
  runtime: nodejs8.10
functions:
  hello:
    handler: modules/hello/handler.hello
    events:
      - http:
          path: hello
          method: get

What am I doing wrong?

mattmeye commented 6 years ago

Have you checked the node_modules folder? is serverless-offline really installed?

dherault commented 6 years ago

I think this is a npm issue (try npm install). Closing.

ndeitch commented 6 years ago

It's necessary to have all dependencies (even devDependencies) on deploy.

In Jenkins on deploy time We didn't have devDeps on node_modules that's because I was getting that error.

ksteigerwald commented 5 years ago

I am having this problem, here are my deps:

 "dependencies": {
    "@octokit/rest": "^15.15.1",
    "@types/axios": "^0.14.0",
    "@types/node": "^10.12.1",
    "axios": "^0.18.0",
    "http": "0.0.0",
    "proxy-agent": "^3.0.3"
  },
  "devDependencies": {
    "@types/aws-lambda": "^8.10.14",
    "serverless-offline": "^3.30.0",
    "serverless-plugin-typescript": "^1.1.5"
  } 
dherault commented 5 years ago

Try remove your node_modules folder and run npm install

ksteigerwald commented 5 years ago

I've tried a few times, no dice. I Cleared out some npm proxy config settings, to see if that might be impacting things. Running npm audit, i get the below warnings:

───────────────┬──────────────────────────────────────────────────────────────┐ │ High │ Insufficient Entropy │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Package │ cryptiles │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Patched in │ >=4.1.2 │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Dependency of │ serverless-offline [dev] │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Path │ serverless-offline > hapi > cryptiles │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ More info │ https://nodesecurity.io/advisories/720 │ └───────────────┴──────────────────────────────────────────────────────────────┘

ksteigerwald commented 5 years ago

I found the issue... Plugins was nested under provider: I moved the plugins key to the bottom and offline starts fine.

robbie-cahill commented 5 years ago

The problem for me was that serverless-offline is under devDependencies. My CI server (like most others) only installs prod dependencies which caused a build failure.

It would be good if it were possible to deploy a project with serverless-offline without moving it to dependencies.

Workaround: move serverless-offline from devDependencies to dependencies

OmarKhattab commented 4 years ago

The problem for me was that serverless-offline is under devDependencies. My CI server (like most others) only installs prod dependencies which caused a build failure.

It would be good if it were possible to deploy a project with serverless-offline without moving it to dependencies.

Workaround: move serverless-offline from devDependencies to dependencies

same issue serverless-offline wouldnt work in devDependencies

elin-y commented 3 years ago

I'd vote to re-open this issue, since it can't be an accepted solution to put serverless-offline to the dependencies, which is definitely a dev dependency!

manishzversal commented 2 years ago

I agree with @elin-y , serverless-offline is a very big package ( on disk size), which is another reason why putting serverless-offline to the dependencies is not a good idea.

https://packagephobia.com/result?p=serverless-offline

elliotfleming commented 12 months ago

This issue happens when you have NODE_ENV=production which excludes devDependencies from being installed. The only solution is to either add those needed dependencies to dependencies or NOT use NODE_ENV=production and instead rely on another mechanism for checking env in your code.

newbreedofgeek commented 1 month ago

Yep, your NODE_ENV is probably "production", so it excludes installing devDependencies. (i also had this issue)