Nest-cli: WebPack Cannot find module '@nestjs/microservices'

Created on 16 Oct 2019  路  5Comments  路  Source: nestjs/nest-cli

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When trying to build a microservice by running nest build {app_name} webpack fails loading @nestjs/microservices.

My project is using the monorepo mode. I can reproduce the issue in windows and
in alpine linux.

Here is an excerpt from the final microservice main.js in the dist folder:

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = __webpack_require__(1);
const common_1 = __webpack_require__(2);
const microservices_1 = __webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module '@nestjs/microservices'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));

Note: Browsing the discord (channel nestjs-cli), I have noticed that a few other people are having the same problem.

Expected behavior

Should find the reference to @nestjs/microservices and bundle successfully.

Minimal reproduction of the problem with instructions

  1. Create a nestjs monorepo project
  2. Add an app and convert to microservice
  3. Try to build and then run the application

What is the motivation / use case for changing the behavior?

Being able to successfully build micro-service applications in a monorepo structure using the cli.

Environment


WINDOWS

[System Information]
OS Version     : Windows 10
NodeJS Version : v10.16.2
NPM Version    : 6.11.3
[Nest Information]
platform-express version : 6.8.3
microservices version    : 6.8.3
passport version         : 6.1.0
swagger version          : 3.1.0
common version           : 6.8.3
core version             : 6.8.3
jwt version              : 6.1.1

ALPINE LINUX (Docker)

[System Information]
OS Version     : Linux 4.9
NodeJS Version : v10.16.3
NPM Version    : 6.9.0
[Nest Information]
platform-express version : 6.8.3
microservices version    : 6.8.3
passport version         : 6.1.0
swagger version          : 3.1.0
common version           : 6.8.3
core version             : 6.8.3
jwt version              : 6.1.1

Most helpful comment

Just released :)

All 5 comments

Can you share the repository which reproduces your issue?

@kamilmysliwiec the original code base is on a private repository, so I created a demo repo that demonstrates the issues I am facing:
https://github.com/alexbuczynsky/demo-mono-repo-issues

The README contains instructions on how to reproduce the error

I just downloaded and built from master. Loading the lazy modules using the changes you implemented in e9e0c32a0060d7f0a8fa5b02313ca59f820e8d9b for V6.10.5 solves my problem

Looking forward to the release of 6.10.5 :)

Just released :)

Was this page helpful?
0 / 5 - 0 ratings