Npm package works locally but not when deployed

I am struggling to understand why my site works correctly locally, but am getting errors when deployed. The error I am seeing is:

Error: Can’t find npm module ‘jimp’. Did you forget to call ‘Npm.depends’ in package.js within the ‘app’ package?
Object.Npm.require (/app/bundle/programs/server/boot.js:203:17)
at [object Object].Router.route.where (common/routes.js:255:20)
at boundNext (packages/iron_middleware-stack/lib/middleware_stack.js:251:1)
at runWithEnvironment (packages/meteor/dynamics_nodejs.js:110:1)
at packages/meteor/dynamics_nodejs.js:123:1
at [object Object].urlencodedParser (/app/bundle/programs/server/npm/node_modules/meteor/iron_router/node_modules/body-parser/lib/types/urlencoded.js:84:40)
at packages/iron_router/lib/router.js:277:1
at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
at [object Object].hookWithOptions (packages/iron_router/lib/router.js:276:1)
at boundNext (packages/iron_middleware-stack/lib/middleware_stack.js:251:1)

Has anyone experienced this before? I am deploying to Galaxy.

Just in case anyone has the same issue, I have finally got to the bottom of it. The ‘jimp’ npm package was being required in code using Npm.require(“jimp”). I changed it to require(‘jimp’) and that fixed it.

I assume the deployment was looking for ‘require’ rather than Npm.require when bundling everything up.

1 Like

Even better, is using ES2015 import syntax :wink: