Nest js: npm run start fails

夙愿已清 提交于 2021-01-29 10:46:49

问题


I'm trying to create a Nest js application, but when I follow the steps on their website, the first error I get is 'cannot find ts-node'. So, I installed that. There were a couple more typscript modules I needed to install (typscript and tsconfig-paths I believe) and when I cleared those errors up and run npm run start I got a 'Cannot find node module @nestjs/core'.


回答1:


As soon as you are working with typescript you have to install it in order to be able to use the tsc command which will transpille your code to javascript.

you also need to install ts-node when you want to work with a transpillation on the fly. that's why you need it.

Finally, you missing to install the necessary packages to be able to work with nest which are listed at this url: https://docs.nestjs.com/

using the following command: $ npm i --save @nestjs/core @nestjs/common rxjs reflect-metadata

Actually, you are missing the @nestjs/core as well as the @nestjs/common packages which are fundamental.




回答2:


[RELATED UPDATE]

I'm running Node v12.14.1 and npm v6.13.4 on a MacBook Pro 13", Late 2011, running macOS High Sierra.

For the past few weeks I have been trying (not continuously) to find an issue, where I would try to run Node well known frameworks, namely NestJS and NextJS, without success, in a similar manner than suggested in this post.

After following the "getting started" instructions, whenever I would run npm run start (NestJS) or npm run dev(NextJS) , in both cases the app would just die silently, no feedback at all, no error message, no nothing. Just stopped.

Last try was to repeat the same steps on Ubuntu 18.04.2 LTS with exactly the same versions Node v12.14.1 and npm v6.13.4 and everything worked fine.

To wrap up, I don't know the cause, I have a vague idea of having read that there is a know issue with npm and latest version(s) of webpack, but for me what got it working was to use yarn instead of npm .

yarn start (NestJS) or yarn dev(NextJS) did the job.



来源:https://stackoverflow.com/questions/56361446/nest-js-npm-run-start-fails

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!