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

Created on 30 Mar 2018  路  5Comments  路  Source: maticzav/graphql-shield

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.

Most helpful comment

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

All 5 comments

It seems chalk should be listed in a peer dependency in this library.

Workaround until that is done is to install chalk as a dependency in your own project.

@skovhus Yes, that workaround does work.

@maticzav Need to list chalk as a dependency in the graphql-shield library.

This is also done in the 2.x branch.

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

Thanks for building this! 馃憤 : )

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dogscar picture dogscar  路  6Comments

nolandg picture nolandg  路  5Comments

OGNeutron picture OGNeutron  路  4Comments

tnolan8 picture tnolan8  路  5Comments

artemzakharov picture artemzakharov  路  8Comments