Answer the question
In order to leave comments, you need to log in
How to properly set file paths in nodejs backend?
How to get rid of this problem
const env = require("../../../../../config/env");
as an option I see something like
const env = require(root + "config/env");
I saw when building the frontend addresses like "@/config/env", is it possible to implement this if I don't use any build systems or a transpiler
Answer the question
In order to leave comments, you need to log in
set NODE_PATH=./&&node index.js
set NODE_PATH=./
is an indication of a global variable NODE_PATH
to search for modules in the project, in addition to node_modules. node index.js
is the launch of the application. && is a command separator
Alternatively, put it in package.json in the scripts section. For example
...
"scripts": {
...
"dev":"set NODE_PATH=./&&node index.js"
...
}
const env = require("config/env");
It is immediately obvious that you do not use tests in your development.
It is wrong to prescribe configs in source codes. Learn TDD.
Environment from the system is read automatically into the process.env object.
For everything else, there are some state machines .
How they work well on the fingers chewed in the vidosik .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question