Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yarn run should provide NODE, like npm run #2609

Closed
wmertens opened this issue Feb 1, 2017 · 5 comments
Closed

yarn run should provide NODE, like npm run #2609

wmertens opened this issue Feb 1, 2017 · 5 comments
Assignees

Comments

@wmertens
Copy link

wmertens commented Feb 1, 2017

Do you want to request a feature or report a bug?

bug

What is the current behavior?

The environment variable NODE is not set when running yarn run anyscript.

If the current behavior is a bug, please provide the steps to reproduce.

  1. Define script env: "echo $NODE"
  2. Run npm run env
  3. Run yarn run env

What is the expected behavior?
2 and 3 return same value, the path to the node executable

Please mention your node.js, yarn and operating system version.
Node 7, Yarn 0.19.1, OS X 10.12.2

@Daniel15
Copy link
Member

Daniel15 commented Feb 1, 2017

Is this documented in the npm documentation somewhere?

@wmertens
Copy link
Author

wmertens commented Feb 1, 2017 via email

@wmertens
Copy link
Author

wmertens commented Feb 1, 2017 via email

@Meligy
Copy link

Meligy commented Feb 6, 2017

Worth noting that there's more in the paragraph that documents the behaviour in the run-scripts page:

npm run sets the NODE environment variable to the node executable with which npm is executed. Also, if the --scripts-prepend-node-path is passed, the directory within which node resides is added to the PATH. If --scripts-prepend-node-path=auto is passed (which has been the default in npm v3), this is only performed when that node executable is not found in the PATH.

It even gives a warning if you call npm run with a custom Node binary (say, portable Node on Windows) and you have a global Node installation, and don't provide --scripts-prepend-node-path.

On a Windows 8.1 machine with Node 6.9.4 and npm 4.1.1, the warning says:

npm WARN lifecycle The node binary used for scripts is C:\Program Files\nodejs\node.exe but npm is using D:\path\to\custom\nodejs\node.exe itself. Use the --scripts-prepend-node-path option to include the path for the node binary npm was executed with.

@BYK BYK self-assigned this Aug 24, 2017
BYK added a commit that referenced this issue Aug 25, 2017
**Summary**

Fixes #2609. This patch adds a `$NODE` environment variable when running
scripts through `yarn run` which is set to `process.execPath` unless it
is formerly set to something else. `$npm_node_execpath` is now just an
alias to `$NODE`.

The patch also updates `yarn env` to show these extra environment
variables.

**Test plan**

Updates existing `yarn env` tests.
@BYK BYK closed this as completed in #4260 Aug 25, 2017
BYK added a commit that referenced this issue Aug 25, 2017
…se (#4260)

**Summary**

Fixes #2609. This patch adds a `$NODE` environment variable when running
scripts through `yarn run` which is set to `process.execPath` unless it
is formerly set to something else. `$npm_node_execpath` is now just an
alias to `$NODE`.

The patch also updates `yarn env` to show these extra environment
variables.

**Test plan**

Updates existing `yarn env` tests.
@wmertens
Copy link
Author

wmertens commented Aug 25, 2017 via email

joaolucasl pushed a commit to joaolucasl/yarn that referenced this issue Oct 27, 2017
…se (yarnpkg#4260)

**Summary**

Fixes yarnpkg#2609. This patch adds a `$NODE` environment variable when running
scripts through `yarn run` which is set to `process.execPath` unless it
is formerly set to something else. `$npm_node_execpath` is now just an
alias to `$NODE`.

The patch also updates `yarn env` to show these extra environment
variables.

**Test plan**

Updates existing `yarn env` tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants