question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Cannot find module 'chalk' when using graphql-shield in production

See original GitHub issue

My Node.js app runs perfectly fine in development mode.

On running the app in production (by setting NODE_ENV to production or using npm install --production), it throws the following error:

Error: Cannot find module 'chalk'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/example/app/node_modules/graphql-shield/dist/src/index.js:56:15)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/example/app/src/graphql/index.js:1:82)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)

If I do just npm install on my production server without the --production flag, all works well but I suppose that’s not a solution since I don’t want to take up space installing devDependencies on my production server.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
maticzavcommented, Apr 2, 2018

Thank you all so much for fixing this! Great work!

1reaction
skovhuscommented, Apr 2, 2018

Thanks for building this! 👍 : )

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Cannot find module 'chalk' when using graphql-shield in ...
My Node.js app runs perfectly fine in development mode. On running the app in production (by setting NODE_ENV to production or using npm ......
Read more >
Error [ERR_MODULE_NOT_FOUND]: Cannot find module
This answer was the one that helped me! I was using import and the file was .js - Adding --es-module-specifier-resolution=node saved the day...
Read more >
What does it take to support Node.js ESM? – The Guild
I have worked on all The Guild's libraries and graphql-js to support ESM. Here is how you can do it too.
Read more >
vDd - River Thames Conditions - Environment Agency - GOV.UK
Russian orthodox cross symbol meaning, Module 1 bike test 2012, Quilting by the bay ... Stanage pole missing, Dubio tutissimus ibis, Lucasfan games...
Read more >
Error: Cannot find module 'chalk' - ERPNext Forum
Please install yarn using below command and try again. npm install -g yarn > frappe@ production /home/frappe/frappe-bench/apps/frappe ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found