3
0
Fork 0
mirror of https://gitea.com/actions/setup-python.git synced 2024-11-22 18:19:35 +01:00
setup-python/node_modules/run-node
Danny McCormick 39c08a0eaa Initial pass
2019-06-26 21:12:00 -04:00
..
license Initial pass 2019-06-26 21:12:00 -04:00
package.json Initial pass 2019-06-26 21:12:00 -04:00
readme.md Initial pass 2019-06-26 21:12:00 -04:00
run-node Initial pass 2019-06-26 21:12:00 -04:00

run-node Build Status

Run the Node.js binary no matter what

You can't always assume running $ node file.js will just work. The user might have the node binary in a non-standard location. They might be using a Node.js version manager like nvm, which is sourced in a subshell and not available from the outside. It also depends from where you're trying to run it. For example, GUI apps on macOS doesn't inherit the $PATH, so the node binary would not be found. Most projects that depend on Node.js just end up telling the user to manually set the full path to the node binary in some project specific settings. Now every project has to do this. Ugh... I prefer things to just work. With this module it will.

This Bash script uses some tricks to find the Node.js binary on your system and run it.

Can be used from any environment that can spawn a process (Shell, Python, Ruby, Swift, Objective-C, etc).

npm

Install

$ npm install run-node

Usage

$ ./node_modules/.bin/run-node file.js

Or in an npm run script:

{
	"start": "run-node file.js"
}

Manually

Install

Download the run-node file:

$ curl -sSLO https://github.com/sindresorhus/run-node/raw/master/run-node && chmod +x run-node

Usage

./run-node file.js

Customizable cache path and error message

The cache path and error message are defined by the RUN_NODE_CACHE_PATH and RUN_NODE_ERROR_MSG environment variables. You could use them in a script or add them to your ~.bashrc.

Default config:

export RUN_NODE_ERROR_MSG="Couldn't find the Node.js binary. Ensure you have Node.js installed. Open an issue on https://github.com/sindresorhus/run-node"
export RUN_NODE_CACHE_PATH="/home/username/.node_path"

Created by

License

MIT © Sindre Sorhus