1

My serverless project is working fine on local when I run it using sls offline start but when I'm trying to deploy it via the command line using serverless deploy I'm getting the following error stack.

internal/modules/cjs/loader.js:1030
  throw err;
  ^

Error: Cannot find module '/Users/rasikraj/Desktop/aws-social/--max-old-space-size=2048'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1027:15)
    at Function.Module._resolveFilename (pkg/prelude/bootstrap.js:1346:46)
    at Function.Module._load (internal/modules/cjs/loader.js:896:27)
    at Function.Module.runMain (pkg/prelude/bootstrap.js:1375:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

What could be causing this issue and how can I resolve it ?

I'm using Sevrerless version :

Framework Core: 2.19.0 (standalone)
Plugin: 4.4.2
SDK: 2.3.2
Components: 3.4.7

Node v12.20.1 and typescript

and this boilerplate https://github.com/AnomalyInnovations/serverless-typescript-starter

Rasik
  • 893
  • 1
  • 8
  • 30
  • Take a look https://stackoverflow.com/questions/42880987/serverless-framework-with-aws-lambda-error-cannot-find-module – Sam Jan 16 '21 at 12:46

2 Answers2

1

It worked for me:

1 - install serverless as a devDependency with yarn or npm

yarn add serverless -D

2 - run the deploy command once again

sls deploy

3 - If the error stills, look at your package json and chech if the serverless is as a devDependency. If it is as normal dependency you can move it to devDependency

5 - Delete the node_modules and run the command:

yarn

or

npm install
0

As the message states, it is looking for a module at "/Users/rasikraj/Desktop/aws-social/--max-old-space-size=2048".

The error makes sense because the odds of you actually having a file named --max-old-space-size=2048 in the aws-social directory are remarkably low.

To me, the filename --max-old-space-size=2048, looks very much intended as a commandline argument to something.

John Mee
  • 50,179
  • 34
  • 152
  • 186