dotenv-flow files can have names like: .env, .env.development, .env.development.local, ...
see: https://www.npmjs.com/package/dotenv-flow
I would like my node server to restart as soon as I update one of those files. However, adding a custom config, I am able to restart on a change in the .env file only.
"nodemonConfig": {
"watch": [".env"]
}
How could I watch files prefixed with .env ?
When overriding nodemon's watch list you need to provide a full match list. For example, to watch js files in the app directory, .env, and files prefixed with .env e.g. .env.development, you can use the following:
nodemon.json
{
"watch": ["app/*.js", ".env", ".env.*"]
}
The same concept works for dotenv-flow
dotenv-flow
"nodemonConfig": {
"watch": ["app/*.js", ".env", ".env.*"]
}
You'll likely need to modify the watch list a bit more to suit your needs. All in all, that's the gist.
Related
I have a Webpack-templated Vue project, initiated through vue-cli.
I have created a simple 'vue.config.js' file stored in the root folder (where package.json is at) containing the following:
// vue.config.js
module.exports = {
productionSourceMap: false
}
Though when building the project using "npm run build" it ignores it.
I have tried different configurations to check if the problem is with the file or the setting, and the problem is with the file.
I am using webpack#3.12.0, vue#2.6.11, #vue/cli 4.2.3 and npm#6.9.0.
Make sure your build confiuration (in your case the webpack build configs) include your file.
Generally, you will have a source folder (often src) and the builder will build all the files in that dir only. Then you have your destination directory (often dist or build) where your build files will be stored.
Two solutions:
add your conf file to the build source.
move your vue.conf.js file into your source directory
For some reason, I did not manage to get vue.config.js to work.
Alternatively, I edited my webpack config, which as my build files mentioned was located at /config/index.js
Then, I proceeded to pass my build configurations to the build parameter which already appears on the file.
build: {
...
}
And it worked. I assume it may be because I used npm run dev instead of the vue-service-cli, so webpack did not go through the vue.config.js file.
When you start an app built by electron,
C¥Users¥UserName¥AppData¥Roaming¥builtProductName¥logs
the directory would be created.
You can find C¥Users¥UserName¥AppData¥Roaming¥Visual Studio Code¥logs
directory if you are using VSCode.
What is this directory?
And is there any way to prevent this directory to be created, when you build an electron app?
// package.json
"build": {
"productName": "**********"
}
It sounds like electron-log is being used. Based on the log file options, you can provide a file option set to a file location you want or disable the file transport altogether with log.transports.file.level = false;.
We have an Angular 7 project and are trying to replace files dynamically without definitely all of the different files in the angular.json file. For instance, when you use the --prod flag after ng build, angular.json will replace environment.ts with environment.prod.ts.
We have another file that contains application specific configuration settings that change depending on the installation. For instance, if we are deploying the project for one client, we may want to run ng build --prod --configuration=clientOne to use that client's specific config file. In this scenario, you'd expect to see something like the below in the angular.json file.
"clientOne": {
"fileReplacements": [{
"replace": "src/app/clientSettings.ts",
"with": "src/app/clientSettings.clientOne.ts"
}]
}
Here's the main question: How can we ask angular.json to replace the clientSettings.ts file with other files based on environment flags, such as --configuration=clientOne, without actually specifying each option in the angular.json. We don't want other developers using the software knowing what installations we have and we don't need to know which ones they have. We want to replace files dynamically without specifying what they are anywhere. We could git ignore the file but that doesn't seem practical.
I use Atom to write code. It uses tsconfig.json to include and exclude folders. In order to use intellisense I need node_modules to be included, but when I want to compile it to js I don't want node_modules to be compiled.
So I need to call tsc in the upper folder where the config.ts is, and this results in compiling the whole node_modules.
My folder structure looks like this:
node_modules
config.ts
spec
|--test1.ts
|--test2.ts
Any idea how to exclude node_modules when compiling with tsc command?
Use exclude property
{
"compilerOptions": {
...
}
"exclude": [
"node_modules"
]
}
Files included using "include" can be filtered using the "exclude" property. However, files included explicitly using the "files" property are always included regardless of "exclude". The "exclude" property defaults to excluding the node_modules, bower_components, jspm_packages and directories when not specified.
link updated:
https://www.typescriptlang.org/tsconfig#exclude
I have a website using nodejs. Problem is when user upload images the site stop working. That because of PM2 restart server when file change I think. How to solve this problem.
thank you
PM2 has special flag --ignore-watch flag.
Try creating file process.json in the same directory where your app.js/index.js is and paste this:
{
"watch": ["server", "client"],
"ignore_watch" : ["node_modules", "public/images"],
"watch_options": {
"followSymlinks": false
}
}
More on that topic: http://pm2.keymetrics.io/docs/usage/watch-and-restart/
A simple explanation, from actual experience
create a json file in the root folder of the the expressjs application. It can have any name, but I used pm2-process.json for clarity
{
"script": "bin/www",
"watch": true,
"ignore_watch": ["log"],
"watch_options": {
"followSymlinks": false
},
"name": "YOUR_PM2_PROCESS_NAME"
}
To start your pm2 service from terminal, in the root folder of the express application:
pm2 start pm2-process.json
That's it. Really simple. There are many other options but this is the bare functional minimum .
Fields explanation:
script - the script to run the express application
watch - a boolean flag to control if pm2 watches (or not) the folder
ignore_watch - if watch is on, then tell pm2 which folders to ignore watching (in other words, this is a watch monitor exclusion list)
name - the name of the pm2 process ('service'). Set it to your application name of choice.
The full documentation is here: http://pm2.keymetrics.io/docs/usage/application-declaration/#attributes-available
Note: I left the node_modules folder out of the ignore_watch array in the example above, because I want pm2 to restart the service after a git pull and npm i that causes a change in the node modules. However it easy to ignore node_modules or any other folder (e.g., temp, public, etc.) by editing the array values