Code Monkey home page Code Monkey logo

typescript-starter's Introduction

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Donate us Support us Follow us on Twitter

Description

Nest framework TypeScript starter repository.

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

typescript-starter's People

Contributors

allenfang avatar alsoicode avatar beeman avatar blazeu avatar brunnerlivio avatar dependabot[bot] avatar fanybook avatar fishuke avatar h4ad avatar hiagodotme avatar kamilmysliwiec avatar konradlinkowski avatar lambdacasserole avatar linkfly avatar maximzinovik avatar mchelen avatar micalevisk avatar nosfistis avatar onozaty avatar progral avatar renovate-bot avatar rpihlak avatar rubencodeforges avatar rubiin avatar sacro avatar samverschueren avatar schinvendy avatar tony133 avatar whitekiwi avatar yurykozhenov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

typescript-starter's Issues

Consider additional maintainers?

As the maintainer of several open source projects myself in addition to having a full-time job and family, time is sometimes in short supply. Fortunately, my wife is a very understanding, kind soul who gives me plenty of time to code :)

I, and I'm sure other, would like to be able to contribute to Nest and keep it moving forward. Would you be interested in bringing on some additional maintainers?

VSCode Debug not working as expected

Created new project using nest cli and running npm run start:debug command but it is just sitting and doing nothing npm run start:dev works but then no debugging

with npm run start:debug the output is coming as below

image

This should be fix as per #37 but still not fixed and mentioned bug #37 should be reopen

TSError: β¨― Unable to compile TypeScript

src/server.ts (5,5): Property 'listen' does not exist on type 'Promise<INestApplication>'. (2339)
    at getOutput (/Users/ochervak/Projects/nest-typescript-starter/node_modules/ts-node/src/index.ts:307:15)
    at /Users/ochervak/Projects/nest-typescript-starter/node_modules/ts-node/src/index.ts:336:16
    at Object.compile (/Users/ochervak/Projects/nest-typescript-starter/node_modules/ts-node/src/index.ts:496:11)
    at Module.m._compile (/Users/ochervak/Projects/nest-typescript-starter/node_modules/ts-node/src/index.ts:392:43)
    at Module._extensions..js (module.js:579:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/Users/ochervak/Projects/nest-typescript-starter/node_modules/ts-node/src/index.ts:395:12)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)

Reflector not injected.

Hello there,
I followed the tutorial to create a role guard with reflector injected https://docs.nestjs.com/guards
At runtime, nest throws an exception where we call .get() like so.
const roles = this.reflector.get<string[]>('roles', handler);
Looks like injector was not made available.

[Nest] 5448 - 2018-2-2 13:23:52 [ExceptionsHandler] Cannot read property 'get' of undefined
TypeError: Cannot read property 'get' of undefined at RoleGuard.canActivate (C:\Users\nest\project\src\core\role.guard.ts:11:34) https://docs.nestjs.com/guards

Can you pls check it out?

Dependencies/versions in package.json
"dependencies": {
"@nestjs/common": "^4.5.9",
"@nestjs/core": "^4.5.10",
"@nestjs/microservices": "^4.5.8",
"@nestjs/testing": "^4.5.5",
"@nestjs/websockets": "^4.5.8",
"@types/express-jwt": "0.0.38",
"body-parser": "^1.18.2",
"express-jwt": "^5.3.0",
"jwks-rsa": "^1.2.1",
"redis": "^2.7.1",
"reflect-metadata": "^0.1.12",
"rxjs": "^5.5.6",
"typescript": "^2.6.2"
}

.nestcli.json file missing

at code
there is no .nestcli.json file existing, so for example
nest g co about
command returning error.

nest g co about
(node:16896) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'c:\ozel\nestjs\apps\nestjs-ts-starter-orig.nestcli.json'
(node:16896) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:16896) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Bump ts-node since it doesn't kill server properly on terminal close

ts-node 4.x has issues when the terminal ts-node is running on gets exited not using CTRL+C (e.g. close the terminal). This means that the server continues to run in the background, the developer must identify the process id on the port and only then can completely terminate the process. Otherwise he receives an 'EADDRINUSE, Address already in use' error when the application is started again.

Bumping the ts-node version to 6 will fix this issue.

Production Run Dependencies

In order to be able to run start:prod I needed to move @types/node from devDependencies to dependencies otherwise I got the following error:

> [email protected] prestart:prod /usr/src/app
> rm -rf dist && tsc
node_modules/@nestjs/common/interfaces/external/mqtt-options.interface.d.ts(1,23): error TS2688: Cannot find type definition file for 'node'.
node_modules/@nestjs/common/interfaces/external/mqtt-options.interface.d.ts(96,31): error TS2304: Cannot find name 'Buffer'.
node_modules/@nestjs/common/interfaces/external/mqtt-options.interface.d.ts(96,40): error TS2304: Cannot find name 'Buffer'.
node_modules/@nestjs/common/interfaces/external/mqtt-options.interface.d.ts(100,32): error TS2304: Cannot find name 'Buffer'.
node_modules/@nestjs/common/interfaces/external/mqtt-options.interface.d.ts(100,41): error TS2304: Cannot find name 'Buffer'.
node_modules/@nestjs/common/interfaces/external/mqtt-options.interface.d.ts(104,30): error TS2304: Cannot find name 'Buffer'.
node_modules/@nestjs/common/interfaces/external/mqtt-options.interface.d.ts(104,39): error TS2304: Cannot find name 'Buffer'.
node_modules/@nestjs/common/interfaces/external/multer-options.interface.d.ts(1,23): error TS2688: Cannot find type definition file for 'node'.
node_modules/@nestjs/common/interfaces/external/multer-options.interface.d.ts(49,17): error TS2304: Cannot find name 'Buffer'.
node_modules/@nestjs/common/interfaces/http/http-server.interface.d.ts(1,23): error TS2688: Cannot find type definition file for 'node'.
node_modules/@nestjs/common/interfaces/http/http-server.interface.d.ts(2,49): error TS2307: Cannot find module 'http'.
node_modules/@nestjs/common/interfaces/nest-fastify-application.interface.d.ts(1,23): error TS2688: Cannot find type definition file for 'node'.
node_modules/@nestjs/common/interfaces/nest-fastify-application.interface.d.ts(45,33): error TS2304: Cannot find name 'Buffer'.
node_modules/@nestjs/common/interfaces/nest-fastify-application.interface.d.ts(63,17): error TS2304: Cannot find name 'Buffer'.
node_modules/@nestjs/core/nest-application.d.ts(1,23): error TS2688: Cannot find type definition file for 'node'.
node_modules/@nestjs/core/nest-application.d.ts(10,23): error TS2307: Cannot find module 'http'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] prestart:prod: `rm -rf dist && tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] prestart:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

yarn run test error

Cannot find module '@nestjs/core/errors/exceptions/microservices-package-not-found.exception' from 'testing-module.js'

Support tslint-config-prettier

Just started using the framework and noticed that both tslint and prettier are setup, but aren't working with each other. By default they play nice, however if the tslint or prettier settings are changed they can conflict with one another. There's a module called tslint-config-prettier that integrates both settings together so these always play nice. This means the settings can be updated without issue :)

404 at localhost:3000

The basic setup resulted in a 404 at localhost:3000.

$ npm startΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·       
                                                                                                             
> [email protected] start /home/mclayton/projects/nest-typescript-starterΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·       
> node index.jsΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·       
                                                                                                             
[Nest] 10154   - 5/23/2017, 10:18:46 AM   [NestFactory] Starting Nest application...Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·       
[Nest] 10154   - 5/23/2017, 10:18:46 AM   [InstanceLoader] ApplicationModule dependencies initializedΒ·       
[Nest] 10154   - 5/23/2017, 10:18:46 AM   [NestApplication] Nest application is ready!Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·       
Application is listening on port 3000.Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·       

It seems to be ready, but...

$ curl -I localhost:3000                                                                                     
HTTP/1.1 404 Not Found                                                                                       
X-Content-Type-Options: nosniff                                                                              
Content-Type: text/html; charset=utf-8                                                                       
Content-Length: 14                                                                                           
Date: Tue, 23 May 2017 14:18:52 GMT                                                                          
Connection: keep-alive                                                                                       

Node: v6.10.2
npm: 3.10.10

Absolute import paths cannot be used in production

Issue

Absolute import paths like importΒ { foo } from 'src/utils/foo' work great with ts-node, but fail when running npm run start:prod.

Error

internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'src/utils/foo'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._resolveFilename (/Users/patrick/r/typescript-starter/node_modules/tsconfig-paths/lib/register.js:75:40)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/Users/patrick/r/typescript-starter/dist/main.js:13:15)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)

Here is a fork of typescript-starter with minimal changes to reproduce the issue. Compare changes.

The start:prod command is already changed to include the tsconfig-paths/register module, from

{
  "start:prod": "node dist/main.js"
}

to

{
  "start:prod": "node -r tsconfig-paths/register dist/main.js"
}

unfortunately without any effect.

[examples] More detailed ts examles

Hello @kamilmysliwiec ,

Could you provide more detailed examples for usage of framework in TS ?

It would be cool to have a description of debugging the app when developed in ts and used with ts-node ( How do you use it?)

Some patterns would be also good for:

  • A pattern for usage of an orm like Sequelize.js or mongodb
  • A config pattern that is accessible from modules ( like loading config from file and share accross modules, components )

A better description, for authenticating roles before route controller would be hit would be welcomed.

Thanks in advance,
Danny

hmr doesnt work

I've made a clone of the master branch. Then followed the instructions from readme:
npm run webpack
npm run start:hmr
When I change the "Hello world" in the App.Service the app opened in chrome is not reloading automatically. Also theres no network activity that would show it even tried to reload. Am I missing some kind of step or its not supposed to autoreload when I change anything and save the file?
Im on Windows 10, npm 5.8.0, node v8.11.1

Unable to start

The very first time after clonning this repo, you won't be able to run npm run start:prod due to the changes done in this commit

Do I have to run npm run build before? or there is some missing 'prestart:prod' script?

Jest E2E process hangs after executing all tests

Hi,

Given this test

describe('AppController (e2e)', () => {
  let app: INestApplication;

  beforeAll(async () => {
    const moduleFixture = await Test.createTestingModule({
      imports: [AppModule],
    }).compile();

    app = moduleFixture.createNestApplication();
    await app.init();
  });

  afterAll(async () => {
    await app.close();
  });

  it('/post /graphql', async () => {
    return request(app.getHttpServer())
      .post('/graphql')
      .send({
        query: `{
          users {
            id
          }
        }`,
      })
      .expect(200)
      .expect('{"data":{"users":[{"id":9}]}}');
  });
});

When I run jest, the process does not exit after the tests finish:

capture d ecran 2018-04-01 a 10 23 06

I've tried to call app.close() in the afterAll jest hook but it does not work.

Error: Cannot find module 'rxjs/Observable/of'

This error is displayed after running npm run start.
I followed the steps under "installation" at https://docs.nestjs.com/

the full error is as follows:

Error: Cannot find module 'rxjs/Observable/of'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    at Function.Module._resolveFilename (/home/david/git/nest/test/node_modules/tsconfig-paths/lib/register.js:31:40)
    at Function.Module._load (internal/modules/cjs/loader.js:475:25)
    at Module.require (internal/modules/cjs/loader.js:598:17)
    at require (internal/modules/cjs/helpers.js:11:18)
    at Object.<anonymous> (/home/david/git/nest/test/src/main.ts:7:1)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
    at Module.m._compile (/home/david/git/nest/test/node_modules/ts-node/src/index.ts:422:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/home/david/git/nest/test/node_modules/ts-node/src/index.ts:425:12)

References to incorrect peer dependency [email protected]

Current package.json dev packages has strict references to [email protected] e.g.

warning " > @nestjs/[email protected]" has incorrect peer dependency "[email protected]".
warning " > @nestjs/[email protected]" has incorrect peer dependency "[email protected]".
warning " > @nestjs/[email protected]" has incorrect peer dependency "[email protected]".
warning " > @nestjs/[email protected]" has incorrect peer dependency "[email protected]".

Let's change reference in package.json to "reflect-metadata": "0.1.10" or remove this strict reference inside packages
@nestjs/[email protected]
@nestjs/[email protected]
@nestjs/[email protected]
@nestjs/[email protected]

FAIL test/app.e2e-spec.ts

Hi Kamil,

I hope this can helpful to others using NestJS. An hour ago I installed NestJs in a new project. When I ran $npm run test:e2e the "Test suite failed to run. error TS2349".

This is what I did to solve this issue:
a) Updated "jest" from v23.6.0 to v24.8.0
b) Edited line from "import * as request from 'supertest'; " to "import request from 'supertest'; "

Then the test:e2e: "PASS => Ran all test suites"
Regards and thanks for the NestJs platform.
Ronald

error when trying to run starter

SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Module._extensions..js (module.js:416:10)
at Object.require.extensions.(anonymous function) [as .js] (C:\Users\svak2\code\node_spikes\nest_starter\node_modules\ts-node\src\index.ts:404:14)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (C:\Users\svak2\code\node_spikes\nest_starter\node_modules@nestjs\core\index.js:14:17)
at Module._compile (module.js:409:26)

Debugging in Docker

Hello,

I would like to explain how I achieved to use VSCode debug tools while running my app in a Docker container because it took me some tricks to succeed, where could I explain the procedure and can I create a PR to push the modifications ?
Here are the changes that I would like to add :

  • A new nodemon config file executing the following npm script
  • A new npm script, maybe start:debug-docker, using tsc and then launching the app with node in inspect mode because ts-node in inspect mode has strange behaviours (the breakpoints in VSCode are detected but not triggered) even with a good files mapping in the launch.json file
  • A launch.json configuration using attach to attach the container's Node inspect websocket

Thanks for the awesome tools that you create, hoping that I can help someone trying to achieve the same thing than me πŸ˜„

Path Mapping Issue with tsconfig.ts

Fo some reason, you can't path map with the 'tsconfig.ts' files like one can do in the Angular-CLI projects. I'm wondering if this is a 'ts-node' issue where you need to use 'tsconfig-paths'? If so, Angular-CLI uses 'ts-node' with no dependency that I know of using 'tsconfig-paths'. This is an odd issue with out much documentation on the subject. Any ideas what's going on?

When you run the tsc --traceResolution command the paths still don't show that they have resolved either.

TypeScript Version
2.6.2

Command Executed
tsc

Terminal Compiling Error:
error TS2307: Cannot find module '@env'.

Trace Resolution Error
Resolving module name '@env' relative to base url '/Users/chris.c/Documents/workspace/app/backend/src' - '/Users/chris.c/Documents/workspace/app/backend/src/@env'.

tsconfig.ts file:

`

"compilerOptions": {
     "declaration": false,
     "outDir": "./dist",
     "module": "commonjs",
     "target": "es6",
      "moduleResolution": "node",
     "sourceMap": true,
     "emitDecoratorMetadata": true,
     "experimentalDecorators": true,
     "rootDir": ".",
     "baseUrl": "src",
     "paths": {
             "@env/*": ["environments/*"]
           },
     "typeRoots": [
             "node_modules/@types"
     ]
  },
 "exclude": [
         "node_modules",
         "**/*.spec.ts"
 ]    

`

Rebuilding the sources before start:prod doesn't make sense

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

The start:prod script rebuilds built sources each time (via the prestart:prod script)

Expected behavior

This script should run node without re-building

Minimal reproduction of the problem with instructions

  1. Install nest
  2. Run start:prod

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

Current implementation doesn't make sense. Both commands start and start:prod forces you to wait until sources are built.

In my opinion it's better to keep sources for the production mode, to save time.

I suggest moving rimraf dist command before build, and don't run build before start:prod.

Environment


Nest version: 6.1.1

 
For Tooling issues:
- Node version: v8.15.0  
- Platform: Mac 

Cannot find type definition file for 'node'. (2688)

I get this is error with zero configuration:

/app/backend/node_modules/ts-node/src/index.ts:316
          throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset))
                ^
TSError: β¨― Unable to compile TypeScript
Cannot find type definition file for 'node'. (2688)
src/server.ts (1,29): Cannot find module '@nestjs/core'. (2307)
src/server.ts (2,35): Cannot find module './modules/app.module'. (2307)

integrate with socket io

Hi, I llike this frame work very much.. but im with trouble, how to config the socket io with the framework.. i try to use interface..

if you can give some example that is better

thank you

Why does the prestart:prod script remove the dist folder?

Hi! I'm trying to deploy my first NestJS application and I may be doing something wrong. I can't find the documentation about building for production on the NestJS website.

From the available npm scripts, I've built the application using the build script and I'm trying to run it using the start:prod script. What bugs me is why do we have a prestart:prod script that removes the whole dist folder? The start:prod script can't start anything without it.

I suppose this is a bug and that the prestart:prod script is indeed a prebuild script. I'll gladly submit a PR if someone from the team confirms that bug.

Problem in response.

The first space is not being removed.

In app.service.ts the root () method is returning the string Hello World!. Returning the information, the space disappears. In my tests apparently only the first space is removed.

Enforce indent consistency

I've started playing with nestjs, and specially, with this starter kit, and I've been a bit surprised seeing how you combine both tabs and spaces in the typescript files.

Also, the indent tslint option is disabled, and I think it shoulld be enabled to, at least, define the usage of spaces (not to say there are also files with 4 spaces instead of 2..).

As said, am a newbie, but I don't think this is correct. Is there any specific reason why you made it this way?

E2E/Jest detected open handle

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

Jest has detected the following 1 open handle potentially keeping Jest from exiting:

  ●  TCPSERVERWRAP

      18 |   it('/ (GET)', () => {
      19 |     return request(app.getHttpServer())
    > 20 |       .get('/')
         |        ^
      21 |       .expect(200)
      22 |       .expect('Hello World!');
      23 |   });

      at Test.Object.<anonymous>.Test.serverAddress (../node_modules/supertest/lib/test.js:59:33)
      at new Test (../node_modules/supertest/lib/test.js:36:12)
      at Object.obj.(anonymous function) [as get] (../node_modules/supertest/index.js:25:14)
      at Object.it (app.e2e-spec.ts:20:8)

Expected behavior

Expected the e2e test to run successfully

Minimal reproduction of the problem with instructions

nest new nest-test
cd nest-test
npm run test:e2e -- --detectOpenHandles

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

proper e2e testing

Environment


Nest version: @nestjs/[email protected]

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Compiling Error: Import does not exist on @Module

When builds try to compiler the Typescript Im getting that looks like the Module definition.

Impacted File: app.module.ts (the main core module)

Terminal Error:
17:20:50 Object literal may only specify known properties, and 'imports' does not exist in type '{ modules?: any[]; controllers?: any[]; components?: any[]; exports?: any[]; }'.

Node Version: 9.0.0

Package.json

  "dependencies": {
    "@nestjs/common": "^4.0.2",
    "@nestjs/core": "^4.0.2",
    "@nestjs/microservices": "^4.0.2",
    "@nestjs/swagger": "^1.1.3",
    "@nestjs/testing": "^4.0.2",
    "@nestjs/websockets": "^4.0.2",
    "@types/morgan": "^1.7.35",
    "aws-sdk": "^2.180.0",
    "cookie-parser": "^1.4.3",
    "jsrsasign": "^8.0.4",
    "lodash.defaultsdeep": "~4.6.0",
    "morgan": "^1.9.0",
    "reflect-metadata": "^0.1.10",
    "rxjs": "^5.4.3"
  },
  "devDependencies": {
    "@types/chai": "^4.0.2",
    "@types/express": "^4.0.36",
    "@types/mocha": "^2.2.41",
    "@types/node": "^9.3.0",
    "@types/sinon": "^2.3.3",
    "chai": "^4.1.1",
    "mocha": "^3.5.0",
    "nodemon": "^1.11.0",
    "sinon": "^2.4.1",
    "ts-node": "^4.1.0",
    "tsconfig-paths": "^3.1.1",
    "typescript": "^2.4.2"
  }

npm run start not working

Hello,

I have some issues running this script. I just cloned it on my local machine, i run:
npm install

and then i run :
npm run start

And I have this error :

internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module 'C:\Users\Bruce'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

I did nothing else, and I really don't understand why... Moreover this error only appears on windows. Could you help me ?

Thanks !

Debugging with VSCode

With the latest release of Visual Studio Code - a new feature called Auto Attach was introduced.
To debug your NestJS app enable Auto Attach and edit nodemon.json file to look like this

{
  "watch": ["src"],
  "ext": "ts",
  "ignore": ["src/**/*.spec.ts"],
  "exec": "node --inspect-brk -r ts-node/register src/main.ts"
}

Now just run yarn start:dev and happy hacking!

Cannot find module 'aproba'

How can fix this issue? Thanks.

➜  project git:(master) sudo npm install
Password:
module.js:515
    throw err;
    ^

Error: Cannot find module 'aproba'
    at Function.Module._resolveFilename (module.js:513:15)
    at Function.Module._load (module.js:463:25)
    at Module.require (module.js:556:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npmlog/node_modules/gauge/render-template.js:3:16)
    at Module._compile (module.js:612:30)
    at Object.Module._extensions..js (module.js:623:10)
    at Module.load (module.js:531:32)
    at tryModuleLoad (module.js:494:12)
    at Function.Module._load (module.js:486:3)
➜  project git:(master) subl .
➜  project git:(master) npm i  
module.js:515
    throw err;
    ^

Error: Cannot find module 'aproba'
    at Function.Module._resolveFilename (module.js:513:15)
    at Function.Module._load (module.js:463:25)
    at Module.require (module.js:556:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npmlog/node_modules/gauge/render-template.js:3:16)
    at Module._compile (module.js:612:30)
    at Object.Module._extensions..js (module.js:623:10)
    at Module.load (module.js:531:32)
    at tryModuleLoad (module.js:494:12)
    at Function.Module._load (module.js:486:3)
➜  project git:(master) 

update package.json

can we update packages to latest versions, if this dont causes any problems?

{
"name": "nest-typescript-starter",
"version": "1.0.0",
"description": "Nest TypeScript starter repository",
"license": "MIT",
"scripts": {
"format": "prettier --write "src/**/*.ts"",
"start": "ts-node -r tsconfig-paths/register src/main.ts",
"start:dev": "nodemon",
"start:debug": "nodemon --config nodemon-debug.json",
"prestart:prod": "rimraf dist && tsc",
"start:prod": "node dist/main.js",
"start:hmr": "node dist/server",
"lint": "tslint -p tsconfig.json -c tslint.json",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:e2e": "jest --config ./test/jest-e2e.json",
"webpack": "webpack --config webpack.config.js"
},
"dependencies": {
"@nestjs/common": "^5.1.0",
"@nestjs/core": "^5.1.0",
"@nestjs/microservices": "^5.1.0",
"@nestjs/testing": "^5.1.0",
"@nestjs/websockets": "^5.1.0",
"reflect-metadata": "^0.1.12",
"rxjs": "^6.2.2",
"typescript": "^2.8.0"
},
"devDependencies": {
"@types/express": "^4.16.0",
"@types/jest": "^23.3.1",
"@types/node": "^10.5.5",
"@types/supertest": "^2.0.5",
"jest": "^23.4.2",
"nodemon": "^1.18.3",
"prettier": "^1.14.0",
"rimraf": "^2.6.2",
"supertest": "^3.1.0",
"ts-jest": "^23.0.1",
"ts-loader": "^4.4.2",
"ts-node": "^7.0.0",
"tsconfig-paths": "^3.5.0",
"tslint": "^5.11.0",
"webpack": "^4.16.3",
"webpack-cli": "^3.1.0",
"webpack-node-externals": "^1.7.2",
"ajv": "^6.5.2"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"transform": {
"^.+\.(t|j)s$": "ts-jest"
},
"coverageDirectory": "../coverage"
}
}

Add tsconfig-paths to project

I'm submitting a...

[ ] Regression
[ ] Bug report
[ X ] Feature request

Current behavior

paths section in tsconfig.json is ignored by ts-node, you will need tsconfig-paths for it.

Expected behavior

'paths' section will be recognized

Minimal reproduction of the problem with instructions

{
  "compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "@shared/*": [
        "../shared/*"
      ],
      "@libs/*": [
        "../libs/*"
      ]
    }
  },
 ...
import { Foo } from '@shared/foo'

--> Module not found

upgrade ts-node

The current version ( in package.json ) ignores settings like

noUnusedLocals 
noUnusedParameters
etc

I don't know why only some are ignored.

rimraf should be moved from dependencies to devDependencies

As title is suggesting I don't see any reason why rimraf library should be part of dependencies. It is dependency of prestart:prod script, but I don't see that we are using it anywhere else in project. So I would like to move it to devDependencies.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.