Answer the question
In order to leave comments, you need to log in
How to organize a modular application on NodeJS / Electron so as not to suffer?
There is an application on Electron. The directory structure looks something like this:
├── app
│ ├── build
│ ├── index.html
│ └── src
│ ├── components
│ ├── entry.js
│ ├── MainPage.vue
├── node_modules
├── persistence
│ ├── testmodule.js
│ └── package.json
├── electron.js
├── package.json
└── webpack.config.js
require(path.resolve(__dirname, "/../../persistence/testmodule")) // это из MainPage.vue
require(path.resolve(__dirname, "/../../../persistence/testmodule")) // а это из компонента чуть пониже
require(path.resolve(__dirname, "/../../../../persistence/testmodule")) // и еще пониже :)
"dependencies": {
"persistence" : "file:./persistence"
}
Answer the question
In order to leave comments, you need to log in
About 2
I use the NODE_PATH environment variable to launch the node and the path for require (for a file of any nesting) I prescribe from the project directory. Something like this
package.json:
"scripts": {
"dev": "NODE_PATH=. nodemon app/index.js",
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question