0

enter image description here

my code is returning the same value even if i change the code

I want to know what happened

Kauan
  • 23
  • 1
  • 3

2 Answers2

0

I highly recommend you to remove dist file first and build and rerun your project.

rm -rf dist
npm run build
npm run start:dev

I'm not sure you faced the issue while adding a new model or updated the schema of orm module.

If yes, According to this link NestJS won't automatically copy your assets to the dist folder moreover as I described earlier is not compatible with glob static paths such as entities property in TypeOrmModule.

Kai
  • 101
  • 3
  • I am changing the return of the controller – Kauan Dec 15 '22 at 17:18
  • I faced the same issue, whenever my NestJS does not update its behavior after I changed some code, removing the entire `dist` folder and rebuild the project usually solve the problem. But this is quite annoying if I do this every time. Much appreciate if anyone can explain what is behind the scene and how to correct it. – iyhc Dec 16 '22 at 02:49
  • Yes man! I want to find out what's going on – Kauan Dec 19 '22 at 13:57
  • @Kauan Could you share the entire package.json file of the project? Basically, excepted handling new model of ORM, NestJS always applies new changes whenever you save a file. – Kai Dec 20 '22 at 13:24
  • @iyhc According to this [link](https://docs.nestjs.com/recipes/hot-reload#hot-reload) webpack won't automatically copy your assets to the dist folder moreover as I described earlier is not compatible with glob static paths such as entities property in TypeOrmModule. – Kai Dec 20 '22 at 13:28
  • this is not the problem. Inside the dist folder, the file is compiled, but the return keeps the same – Kauan Dec 21 '22 at 16:52
  • i tried to create another project but the error remains – Kauan Dec 21 '22 at 16:54
  • I did what is written in this 'link' and I solved it, but I wanted to know why the application does not work with 'hot-reload' – Kauan Dec 21 '22 at 16:57
  • @Kauan NestJS is basically provides hot-reload feature. Perhaps you are using lower version of node and nestjs. What version did you make a new NestJS project with? Have you followed up the exact steps on the [official website](https://docs.nestjs.com/first-steps)? – Kai Dec 22 '22 at 12:04
0

Try the following:

Add the rimraf lib:

yarn add rimraf

Then create a new script in the scripts section of the package.json:

"prebuild":"rimraf dist"

mh377
  • 1,656
  • 5
  • 22
  • 41