nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
66.91k stars 7.55k forks source link

Installation and New project #5594

Closed ArfyFR closed 3 years ago

ArfyFR commented 3 years ago

Bug Report

I wanted to try Nest

Current behavior

I did what is written in the doc:

$ npm i -g @nestjs/cli
$ nest new project-name

Same with git version, I mean

$ git clone https://github.com/nestjs/typescript-starter.git project
$ cd project
$ npm install
$ npm run start

And after the npm run start, I got

npm run start

> go-guard-nest@0.0.1 start C:\DEV\GIT\go-guard-nest
> nest start

node_modules/@types/jest/index.d.ts:33:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: describe, fdescribe, xdescribe, it, fit, xit, beforeEach, afterEach, beforeAll, afterAll, expect, CustomEqualityTester, CustomMatcherFactory, DEFAULT_TIMEOUT_INTERVAL

33 declare var beforeAll: jest.Lifecycle;
   ~~~~~~~

  ../node_modules/@types/jasmine/ts3.1/index.d.ts:22:1
    22 type ImplementationCallback = jasmine.ImplementationCallback;
       ~~~~
    Conflicts are in this file.
node_modules/@types/jest/index.d.ts:1369:46 - error TS2314: Generic type 'ArrayContaining<T>' requires 1 type argument(s).

...

node_modules/@types/jest/index.d.ts:1492:9 - error TS2687: All declarations of 'message' must have identical modifiers.

1492         message: string | (() => string);
             ~~~~~~~

Found 34 error(s).

Expected behavior

Run the test/demo project

Possible Solution

Environment


Nest version: 7.5.1


For Tooling issues:
- Node version: v12.19.0  (LTS up to date)
- Platform:  Windows 10            
ArfyFR commented 3 years ago

Full log nest log.txt

kaznovac commented 3 years ago

@ArfyFR try removing the @types/jest (they are for the jest 25, project starter uses jest 26) and import the jest methods in tests import { afterEach, beforeEach, describe, it } from "@jest/globals";

ArfyFR commented 3 years ago

So

  • I removed @types/jest from package.json
  • I removed node_modules
  • I ran npm i again
  • then nest build

Lots of errors. More than 2500.

Next I deleted all, and tried from beginning:

nest new project-name
⚡  We will scaffold your app in a few seconds..

CREATE project-name/.eslintrc.js (663 bytes)
CREATE project-name/.prettierrc (51 bytes)
CREATE project-name/nest-cli.json (64 bytes)
CREATE project-name/package.json (1894 bytes)
CREATE project-name/README.md (3370 bytes)
CREATE project-name/tsconfig.build.json (97 bytes)
CREATE project-name/tsconfig.json (339 bytes)
CREATE project-name/src/app.controller.spec.ts (617 bytes)
CREATE project-name/src/app.controller.ts (274 bytes)
CREATE project-name/src/app.module.ts (249 bytes)
CREATE project-name/src/app.service.ts (142 bytes)
CREATE project-name/src/main.ts (208 bytes)
CREATE project-name/test/app.e2e-spec.ts (630 bytes)
CREATE project-name/test/jest-e2e.json (183 bytes)

? Which package manager would you ❤️  to use? npm
√ Installation in progress... ☕

�  Successfully created project project-name
�  Get started with the following commands:

$ cd project-name
$ npm run start

                          Thanks for installing Nest �
                 Please consider donating to our open collective
                        to help us maintain this package.

               �  Donate: https://opencollective.com/nest

What next ?
Remove the @types/jest in ? Then ?

ArfyFR commented 3 years ago

I found a way to make the "nest new" work on Windows 10 I did what was told here: https://stackoverflow.com/questions/56266800/nestjs-errors-stemming-from-types-dependencies-in-node-modules-when-running-sta By adding this line to tsconfig.json:

"typeRoots": ["./node_modules/@types"],

OzzyTheGiant commented 3 years ago

@ArfyFR Thanks! Can confirm this works on Ubuntu 20.10. For context, I was trying to install Nest alongside Angular in the same repo. Tried to combine the package.json, node_modules, and tsconfig files just for the sake of efficiency but it will not work as they may require different versions of TypeScript and other dependencies, so I installed in a server subdirectory. Kept getting these errors but that typeRoots setting did the trick; I think Nest was picking up Jasmine typings from the parent directory where Angular is at.