Skip to content

freak2geek/run-meteor-node

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"

WSL

By default, node is run from the Windows Subsystem for Linux (WSL) if is not found in the main environment. You could prioritize the WSL usage by setting the RUN_NODE_FORCE_WSL environment variable.

export RUN_NODE_FORCE_WSL=1

Customize the node command

You could use the RUN_NODE_CMD environment variable to use a different command that includes the node execution.

Example:

export RUN_NODE_CMD="meteor node"

Created by

License

MIT © Sindre Sorhus

About

Run the"meteor node" and support WSL.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 100.0%