Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'bignumber.js' #2244

Closed
egalarza007 opened this issue Jul 9, 2019 · 10 comments
Closed

Cannot find module 'bignumber.js' #2244

egalarza007 opened this issue Jul 9, 2019 · 10 comments

Comments

@egalarza007
Copy link

egalarza007 commented Jul 9, 2019

The Parser in lib is throwing missing module warnings

Stack

Error: Cannot find module 'bignumber.js'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (/node_modules/mysql/lib/protocol/Parser.js:4:36)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)

It looks like in the most recent change logs you have updated the version

## v2.17.1 (2019-04-18)

* Update `bignumber.js` to 7.2.1 #2206
  - Fix npm deprecation warning

## v2.17.0 (2019-04-17)

...
* Update `bignumber.js` to 6.0.0
@dougwilson
Copy link
Member

That error usually is because there was an issue during your npm install. Can you run npm install again and paste the output here?

@egalarza007
Copy link
Author

I am building in a cloud environment and the application is serverless.
I piped the content of a local install into file located below.
log.txt

@dougwilson
Copy link
Member

Thanks for the log. It shows that bignumber.js@7.2.1 is being installed successfully somewhere.

Can you run npm ls bignumber.js to see where it installed to?

@egalarza007
Copy link
Author

egalarza007 commented Jul 10, 2019

Thank you Mr Wilson for rapid response. It looks like it is being installed in the correct location but when deployed to Lambda I still get that same Error: Cannot find module 'bignumber.js'
npm ls bignumber.js output

└─┬ serverless-mysql@1.4.0
  └─┬ mysql@2.17.1
    └── bignumber.js@7.2.1

@dougwilson
Copy link
Member

Hm. How does the deployment process work?

@egalarza007
Copy link
Author

egalarza007 commented Jul 10, 2019

It's the same process as run locally sir.
I have a build spec that runs the package.json script for build like

npm run build

The only difference is --only=production to reduce the size of the zip sir
This is the content of scripts in package.json

  "scripts": {
    "test": "jest --coverage",
    "test:update": "jest --verbose --coverage --updateSnapshot",
    "test:watch": "jest --verbose --watch",
    "coverage": "jest --verbose --coverage && open ./coverage/lcov-report/index.html",
    "build": "npm install --only=production",
    "eslint": "./node_modules/.bin/eslint --ignore-path .gitignore ."
  },

@dougwilson
Copy link
Member

So are you able to replicate the error locally? Can you help me repliacate locally? I could then have something in hand to try and debug how to fix.

@egalarza007
Copy link
Author

Mr Wilson-
I just created a unit test and it looks like this issue does not appear locally.
I updated my deployment script to also output the location of bignumber.js after build and it also looks correct sir.
Output below

added 14 packages in 1.608s 
post-slack-event@1.0.0 /codebuild/output/src082596253/src/PostSlackEvent 
`-- serverless-mysql@1.4.0 
  `-- mysql@2.17.1 
    `-- bignumber.js@7.2.1  

I also see the package in node_module

Screen Shot 2019-07-10 at 9 33 34 AM

This issue must be isolated to Lambda runtime for Node.
Thank you for all your help sir.
You may close this issue and I will continue troubleshooting in Lambda.

@egalarza007
Copy link
Author

Mr. Wilson-
I have resolved the issue and it was related to the Lambda deployment. After installing and building the project I would remove certain files to reduce size of zip for deployment. Removal of the .json config files also removed the package.json for the node_modules which prevented Lambda from finding these modules.
Thank you for all your help sir.

@dougwilson
Copy link
Member

Hi @egalarza007 sorry for the late response; I'm glad you were able to get it working :) !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants