I am new to nodejs. Can node resolve ~ (unix home directory) example ~foo, ~bar to /home/foo, /home/bar
> path.normalize('~mvaidya') '~mvaidya' > path.resolve('~mvaidya') '/home/mvaidya/~mvaidya' >
This response is wrong; I am hoping that ~mvaidya must resolve to /home/mvaidya
Solution. The solution to run your Node. js app with increased memory is to start the process with an additional V8 flag: --max-old-space-size . You need to append your desired memory size in megabytes.
By default, Node. js (up to 11. x ) uses a maximum heap size of 700MB and 1400MB on 32-bit and 64-bit platforms, respectively.
SIGINT is generated by the user pressing Ctrl + C and is an interrupt. SIGTERM is a signal that is sent to request the process terminates. The kill command sends a SIGTERM and it's a terminate. You can catch both SIGTERM and SIGINT and you will always be able to close the process with a SIGKILL or kill -9 [pid] .
process. cwd() returns the current working directory, i.e. the directory from which you invoked the node command. __dirname returns the directory name of the directory containing the JavaScript source code file.
As QZ Support noted, you can use process.env.HOME
on OSX/Linux. Here's a simple function with no dependencies.
const path = require('path'); function resolveHome(filepath) { if (filepath[0] === '~') { return path.join(process.env.HOME, filepath.slice(1)); } return filepath; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With