Error Modules & Dependencies production
See original GitHub issueBug Report
Hi everybody, After many attempts, I still get the error that I report below, I have done it with the npm run build command and also with webpack, but it has not worked in any way when I want to pass my project to production.
Apparently it is not loading any module in production.
I really appreciate the help you can give me.
Thanks…
Current behavior
After run ‘node main.js’ in the terminal open this error:
Error: Cannot find module ‘@nestjs/core’ Require stack:
- C:\server\main.js [90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)[39m [90m at Function.Module._load (internal/modules/cjs/loader.js:864:27)[39m [90m at Module.require (internal/modules/cjs/loader.js:1044:19)[39m [90m at require (internal/modules/cjs/helpers.js:77:18)[39m at Object.<anonymous> (C:\server\main.js:118:18) at webpack_require (C:\server\main.js:20:30) at Object.<anonymous> (C:\server\main.js:103:16) at webpack_require (C:\server\main.js:20:30) at C:\server\main.js:84:18 at Object.<anonymous> (C:\server\main.js:87:10) { code: [32m’MODULE_NOT_FOUND’[39m, requireStack: [ [32m’C:\server\main.js’[39m ] }
Input Code
Expected behavior
Possible Solution
Environment
Nest version: 7.5.1
For Tooling issues:
- Node version: 12.6.1
- Platform:
- Nest CLI Version : 7.5.1
Others:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
throwing error while creating production build when using ...
The module that throws you the error is needed in build phase and if you install only production dependencies the build won't succeed....
Read more >Module Dependency Problem - Wiki
The implementation module dependency problem occurs when the tools used to process programs (compilers, interpreters, virtual machines, linkers, loaders, etc.) ...
Read more >Handling Compiler and other Package Dependencies
Basic dependency handling: seeing how well the strategy supports the loading of the correct build of a package depending on the previously loaded...
Read more >Error: module property was removed from Dependency - Issues
I have a Next.js application that I deploy to the Moovweb XDN. After upgrading to @xdn/core version 2.30.2 I get the following error...
Read more >How to Solve the Global npm Module Dependency Problem
The first thing you need to do is remove that -g when you install modules. You should replace that with --save-dev so you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just like with any other node server, you still need your production dependencies. You need the
package.json
, thedist
and thenode_modules
so that node knows how they’re all related to each other. This is the standard approach and not specific to Nest. Please use our Discord for further discussion.@mohsinamjad that’s not really the case for node servers, yes you can use webpack for some of that, but it can’t work with everything, as mentioned in the linked answer, due to requiring underlying lower level processes that could vary from machine to machine (bcrypt and database drivers are two common examples). Because of this, you can webpack it all into a
main
, but you still need to install the dependencies for production.