So `lodash` is a required dependency?
Unanswered
Golden northern bumble bee posted this in #help-forum
Golden northern bumble beeOP
Next 12 here.
I've stumbled upon a weird thing. Since we distribute our app as a docker image we need to reduce its effective size and for that we run
because in
And that - because it uses WebPack which requires it.
I don't think it should work this way, it looks like a bug.
I've stumbled upon a weird thing. Since we distribute our app as a docker image we need to reduce its effective size and for that we run
npm i --omit=dev. Because obviously one doesn't need ANY devDependencies when running an app in production. However, our Next.JS app fails with this message:Error: Cannot find module 'lodash'
Require stack:
- /projects/hb/plmc/packages/4-app/.next/server/pages/_document.js
- /projects/hb/plmc/node_modules/next/dist/server/require.js
- /projects/hb/plmc/node_modules/next/dist/server/next-server.js
- /projects/hb/plmc/node_modules/next/dist/server/next.js
- /projects/hb/plmc/node_modules/next/dist/server/lib/start-server.js
- /projects/hb/plmc/node_modules/next/dist/cli/next-start.js
- /projects/hb/plmc/node_modules/next/dist/lib/commands.js
...because in
.next/server/pages/_document.js there is require('lodash') line!And that - because it uses WebPack which requires it.
I don't think it should work this way, it looks like a bug.
3 Replies
Golden northern bumble beeOP
I think it should be in the readme. And also, create nextjs app template should also add
lodash into "dependencies" thenI spent hours replacing all our
lodash imports with specific atomic ones lodash.isarray, lodash.get and now I see that it was not necessary LOLThere is one more thing.
@next/bundle-analyzer will always add lodash into reports no matter you use it or not.