nestjs / nest-cli

CLI tool for Nest applications 🍹
https://nestjs.com
Other
1.95k stars 389 forks source link

First start error MODULE_NOT_FOUND #724

Closed adithyvisnu closed 4 years ago

adithyvisnu commented 4 years ago

I'm submitting a...


[ x ] Regression 
[ ] 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

I am new into NestJS. My friends told me to use this cool framework, so I tried this.

I am following the instructions on Introductory Documentation to start simple web server.

But when I tried to start the project with npm start or nest start, it turns out to MODULE_NOT_FOUND error

internal/modules/cjs/loader.js:621
  throw e;
  ^

Error: No valid exports main found for '/home/adithya/Documents/repo/nestjs/product-service/node_modules/uuid'
    at resolveExportsTarget (internal/modules/cjs/loader.js:618:9)
    at applyExports (internal/modules/cjs/loader.js:499:14)
    at resolveExports (internal/modules/cjs/loader.js:548:12)
    at Function.Module._findPath (internal/modules/cjs/loader.js:650:22)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:948:27)
    at Function.Module._load (internal/modules/cjs/loader.js:854:27)
    at Module.require (internal/modules/cjs/loader.js:1023:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/home/adithya/Documents/repo/nestjs/product-service/node_modules/@nestjs/common/decorators/core/injectable.decorator.js:3:16)
    at Module._compile (internal/modules/cjs/loader.js:1128:30) {
  code: 'MODULE_NOT_FOUND'
}

Expected behavior

But when I try via alternative installation (pulling a sample repository $ git clone https://github.com/nestjs/typescript-starter.git project) it works well like this.

> nest-typescript-starter@1.0.0 start /home/adithya/Documents/repo/nest/project
> nest start

[Nest] 17377   - 05/15/2020, 10:47:54 AM   [NestFactory] Starting Nest application...
[Nest] 17377   - 05/15/2020, 10:47:54 AM   [InstanceLoader] AppModule dependencies initialized +8ms
[Nest] 17377   - 05/15/2020, 10:47:54 AM   [RoutesResolver] AppController {}: +4ms
[Nest] 17377   - 05/15/2020, 10:47:54 AM   [RouterExplorer] Mapped {, GET} route +2ms
[Nest] 17377   - 05/15/2020, 10:47:54 AM   [NestApplication] Nest application successfully started +1ms

Also the nest information is like this

 _   _             _      ___  _____  _____  _     _____
| \ | |           | |    |_  |/  ___|/  __ \| |   |_   _|
|  \| |  ___  ___ | |_     | |\ `--. | /  \/| |     | |
| . ` | / _ \/ __|| __|    | | `--. \| |    | |     | |
| |\  ||  __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
\_| \_/ \___||___/ \__|\____/ \____/  \____/\_____/\___/

[System Information]
OS Version     : Linux 4.15
NodeJS Version : v13.3.0
NPM Version    : 6.14.5 

[Nest CLI]
Nest CLI Version : 7.0.0 

[Nest Platform Information]
platform-express version : 7.0.1
common version           : 7.0.1
core version             : 7.0.1

Minimal reproduction of the problem with instructions

It occurs when I try to create a new project with a newest nest-cli, but if I used the sample project that I mention above, it works well.

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

It might be a little different result for nest info that used between on a sample project and nest new <project name> so I guess there is something wrong, or did I wrong on starting a new project? I hope there is an explanation for what I am doing wrong and what should I do to create from the newest nest-cli :+1: .

Thank you :grin:

Environment

When I use command nest new <project name> and run the nest info command, the result is

 _   _             _      ___  _____  _____  _     _____
| \ | |           | |    |_  |/  ___|/  __ \| |   |_   _|
|  \| |  ___  ___ | |_     | |\ `--. | /  \/| |     | |
| . ` | / _ \/ __|| __|    | | `--. \| |    | |     | |
| |\  ||  __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
\_| \_/ \___||___/ \__|\____/ \____/  \____/\_____/\___/

[System Information]
OS Version     : Linux 4.15
NodeJS Version : v13.3.0
NPM Version    : 6.14.5 

[Nest CLI]
Nest CLI Version : 7.1.5 

[Nest Platform Information]
platform-express version : 7.0.0
common version           : 7.0.0
core version             : 7.0.0
kamilmysliwiec commented 4 years ago

I can't reproduce your issue locally. This seems to be caused by your Node version & env and the uuid package, see https://github.com/googleapis/google-api-nodejs-client/issues/2090. Updating the Node version should solve this issue.

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.

kyrcha commented 4 years ago

I had the same issue and updating from node v13.6.0 to v14.2.0 resolved it.

adithyvisnu commented 4 years ago

I can't reproduce your issue locally. This seems to be caused by your Node version & env and the uuid package, see googleapis/google-api-nodejs-client#2090. Updating the Node version should solve this issue.

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.

Indeed upgrading node to the newest version resolves this problem. Thank you :+1:

adithyvisnu commented 4 years ago

I had the same issue and updating from node v13.6.0 to v14.2.0 resolved it.

Yes. Me too. I am upgrading from node v13.3.0 to v14.2.0 and works well. Now lets try to dig in nestjs! :grin:

mattiaskjellsson commented 4 years ago

I had the same issue and updating from node v13.6.0 to v14.2.0 resolved it.

How do you run with node 14.x?

The reason I ask is that iI get warnings from @nestjs/cli and @nestjs/schematics dependencies are depricated and will not work with node v14.+


warning @nestjs/cli > webpack > watchpack > watchpack-chokidar2 > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
warning @nestjs/schematics > @angular-devkit/core > chokidar@2.0.4: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
warning @nestjs/schematics > @angular-devkit/core > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
warning jest > jest-cli > @jest/core > jest-haste-map > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
warning jest > jest-cli > jest-config > jest-environment-jsdom > jsdom > left-pad@1.3.0: use String.prototype.padStart()
warning jest > jest-cli > jest-config > jest-environment-jsdom > jsdom > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142```
adrienbarreau commented 4 years ago

@adithyvisnu @mattiaskjellsson FYI using node:13.14 does the trick and do not mess nestjs up... Still think it's a bug that should be solved as it should work for such young nodejs versions as 13..

kamilmysliwiec commented 4 years ago

This is a bug in Node.js, not NestJS.

Please, make sure to use EITHER the current LTS version (12.*, current - 12.18.0) or the latest version (14.4.0)