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 Modules & Dependencies production

See original GitHub issue

Bug 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  at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)  at Function.Module._load (internal/modules/cjs/loader.js:864:27)  at Module.require (internal/modules/cjs/loader.js:1044:19)  at require (internal/modules/cjs/helpers.js:77:18) 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: ’MODULE_NOT_FOUND’, requireStack: [ ’C:\server\main.js’ ] }

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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jmcdo29commented, Sep 8, 2020

Just like with any other node server, you still need your production dependencies. You need the package.json, the dist and the node_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.

0reactions
jmcdo29commented, Jul 16, 2021

@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.

Read more comments on GitHub >

github_iconTop 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 >

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