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

Plug'n'Play does not work with Node 11 #7092

Closed
Turbo87 opened this issue Mar 8, 2019 · 4 comments
Closed

Plug'n'Play does not work with Node 11 #7092

Turbo87 opened this issue Mar 8, 2019 · 4 comments

Comments

@Turbo87
Copy link

Turbo87 commented Mar 8, 2019

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

bug

What is the current behavior?

When using yarn run on Node 11 it does not activate PnP mode automatically when "pnp": true is specified in the package.json file.

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

  • create a new folder
  • yarn init
  • yarn add chalk (just an example)
  • create an index.js file:
let chalk = require('chalk');

console.log(chalk.red('hello'));
  • add a script to package.json so that yarn run foo runs the index.js file
  • yarn run foo (should run fine and print the string in red)
  • yarn --pnp (enable PnP mode)
  • yarn run foo (fails with Error: Cannot find module 'chalk')

when you switch over from Node 11 to Node 10 everything works fine

What is the expected behavior?

yarn run should enable PnP mode automatically on Node 11 too

Please mention your node.js, yarn and operating system version.

OS: macOS 10.13.6
node: 10.15.0 and 11.10.0
yarn: 1.13.0

@rwjblue
Copy link
Contributor

rwjblue commented Mar 8, 2019

@stefanpenner, @davecombs, and myself ran across this issue (discussion over in stefanpenner/resolve-package-path#7). The symptoms that we witness were that in Node 11 any scripts had to manually add -r ./.pnp.js to ensure the .pnp.js was required when ran via yarn test however the same setup worked without manually requiring .pnp.js when ran under Node 10.

@rwjblue
Copy link
Contributor

rwjblue commented Mar 8, 2019

I spent some time digging into this and found the underlying issue in Node 11's parsing of NODE_OPTIONS. I reported that here: nodejs/node#26521.

However, I also went to submit a patch working around the issue but I believe it is already fixed (by #6942 and #6951) on master. Unfortunately, #6951 is not included in 1.14.0 (but #6942 is) so on 1.14.0 some things "work" with Node 11 (e.g. yarn node some-file.js or yarn mocha tests/**.js) but lifecycle scripts do not.

@arcanis
Copy link
Member

arcanis commented Mar 8, 2019

Thanks for the investigation, @rwjblue! That was a good one 😅

I've started the release process for the 1.15 (and will put the 1.14 in stable once it's done), it was time to do it anyway 🙂 the patch should be made available in a few hours.

@Turbo87
Copy link
Author

Turbo87 commented Jun 11, 2019

closing as this got fixed in Node v11.12.0

@Turbo87 Turbo87 closed this as completed Jun 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants