Inside package.json, is it possible to test if node_modules directory exists?
My goal is to print a message if node_module does not exists, something like:
node_module not existent: use npm run dist
where dist is a script inside scripts of my package.json.
Thank you.
I thought I would post what I've done for cross-platform one-liner conditional NPM scripts.
"scripts": {
"start":"(node -e \"if (! require('fs').existsSync('./node_modules'))
{process.exit(1)} \" || echo
'node_module dir missing: use npm run dist') && node start-app.js",
}
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