jhipster / generator-jhipster-nodejs

A NodeJS blueprint that creates the backend using NestJS
https://www.npmjs.com/package/generator-jhipster-nodejs
Apache License 2.0
257 stars 80 forks source link

Error: ENOENT: no such file or directory, open 'XXXXX\server\src\config/application-d.yml' #96

Closed ajoysinhaabbvie closed 4 years ago

ajoysinhaabbvie commented 4 years ago

Describe the bug After creation of nodebased microservice using jhipster import-jdl model-name.jdl --blueprints nodejs, on start of server "npm start" application is looking for a file name application-d.yml. where as application-dev.yml

To Reproduce Steps to reproduce the behavior:

  1. Create a nodejs app using jhipster import-jdl model-name.jdl --blueprints nodejs
  2. go into server folder
  3. run npm install
  4. run npm start

Application is giving error as below [nodemon] starting ts-node src/main.ts Error: ENOENT: no such file or directory, open 'D:\microservices\services\usermicroservice\server\src\config/application-d.yml'

Expected behavior application should start

Note : if you change the application-dev.yml into application-d.yml, then application is starting smoothly

ghost commented 4 years ago

Hi @ajoysinhaabbvie, thanks to use NHipster.. every feedback is very important. So, could you explain what version of blueprint are you using? The last release passed every integration test that covers your use case: https://github.com/jhipster/generator-jhipster-nodejs/runs/384846320

ajoysinhaabbvie commented 4 years ago

I am using : generator-jhipster-nodejs@1.0.0-beta.2 I have created nodejs microservice app from jdl file. and then run the application server. attaching the screenshots for your reference .. hope this will help ..

If i do rename application-dev.yml to application-d.yml then system is working .

screenshot1 screenshot2

ajoysinhaabbvie commented 4 years ago

Attaching jdl file for your reference Please change name from .txt to .jdl

app.jdl.txt

ghost commented 4 years ago

Maybe I have understand your problem.. Can you check what is the value of the node system variable NODE_ENV? It is used in the app starting: https://github.com/jhipster/generator-jhipster-nodejs/blob/927622480140e64c12437c0f979ab8f64c1f8f69/generators/server/templates/server/src/config/config.ts.ejs#L91

So to change it you can rewrite value in your env project file

The value must be dev, prod or test.

If it is the problem, I can provide in the startup a code check if the NODE_ENV value (that is the app profile) is allowed having a related application.yml

ghost commented 4 years ago

Hi @ajoysinhaabbvie, any news???

kosnkow commented 4 years ago

we had the same problem so we changed: -const yamlConfig = yaml.safeLoad(fs.readFileSync(dirname + '/application.yml', 'utf8')); -const envYamlConfig = yaml.safeLoad(fs.readFileSync(dirname + /application-${process.env.NODE_ENV}.yml, 'utf8')); +const yamlConfig = yaml.safeLoad(fs.readFileSync(dirname + '/../../config/application.yml', 'utf8')); +const envYamlConfig = yaml.safeLoad(fs.readFileSync(dirname + /../../config/application-${process.env.NODE_ENV}.yml, 'utf8'));

ghost commented 4 years ago

It is linked to #99 that has more details.

ghost commented 4 years ago

Fix with #102 , I will release the 1.0.0-beta.3

ghost commented 4 years ago

Hi @ajoysinhaabbvie and @kosnkow , you can test the new version just published 1.0.0-beta.3. Feel free to open new issues if there are another problems. Thanks!