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: Error: Cannot find module #6626

Closed
pustovalov opened this issue Nov 2, 2018 · 16 comments
Closed

Plug'n'Play: Error: Cannot find module #6626

pustovalov opened this issue Nov 2, 2018 · 16 comments
Assignees

Comments

@pustovalov
Copy link

pustovalov commented Nov 2, 2018

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

Bug

What is the current behavior?

When doing yarn install, I get an error

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

  1. Run yarn
  2. Get an error
yarn install v1.12.1
warning package.json: No license field
warning No license field
[1/5] 🔍  Resolving packages...
[2/5] 🚚  Fetching packages...
[3/5] 🔗  Linking dependencies...
[5/5] 📃  Building fresh packages...
error /Users/pavel/main/.pnp/unplugged/npm-node-sass-4.9.4-349bd7f1c89422ffe7e1e4b60f2055a69fbc5512/node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: /Users/pavel/main/.pnp/unplugged/npm-node-sass-4.9.4-349bd7f1c89422ffe7e1e4b60f2055a69fbc5512/node_modules/node-sass
Output:
Building: /usr/local/Cellar/node/11.0.0/bin/node /Users/pavel/Library/Caches/Yarn/v3/npm-node-gyp-3.8.0-540304261c330e80d0d5edce253a68cb3964218c/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
internal/modules/cjs/loader.js:589
    throw err;
    ^

Error: Cannot find module 'graceful-fs'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:587:15)
    at Function.Module._load (internal/modules/cjs/loader.js:513:25)
    at Module.require (internal/modules/cjs/loader.js:643:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/Users/pavel/Library/Caches/Yarn/v3/npm-node-gyp-3.8.0-540304261c330e80d0d5edce253a68cb3964218c/node_modules/node-gyp/lib/node-gyp.js:12:10)
    at Module._compile (internal/modules/cjs/loader.js:707:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
    at Module.load (internal/modules/cjs/loader.js:605:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
    at Function.Module._load (internal/modules/cjs/loader.js:536:3)
Build failed with error code: 1
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

What is the expected behavior?
Package successfully installed. Without PnP all works fine.

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

{
  "dependencies": {
    "node-sass": "^4.9.4"
  },
  "installConfig": {
    "pnp": true
  }
}

MacOS 10.14.1
Node 11.0.0
Yarn 1.12.1

@ghost ghost assigned rally25rs Nov 2, 2018
@ghost ghost added the triaged label Nov 2, 2018
@pustovalov
Copy link
Author

Works with Node 10.13.0

@mischnic
Copy link

mischnic commented Nov 2, 2018

@arcanis
Copy link
Member

arcanis commented Nov 2, 2018

@mischnic no, this thread is pnp specific 🙂

I need to investigate, but it seems node-gyp.js is called without the PnP hook being setup. This is because the node binary used by node-gyp isn't the one provided by Yarn (which is a shellscript automatically calling the right binaries with the right arguments).

@arcanis
Copy link
Member

arcanis commented Nov 2, 2018

Theoretically this node indirection should be in the $PATH, meaning that node-gyp isn't respecting it entirely 🤔

@arcanis
Copy link
Member

arcanis commented Nov 3, 2018

I cannot reproduce it on Linux (WSL, actually) 🙁

@mischnic
Copy link

mischnic commented Nov 3, 2018

Can reproduce on macOS 10.13.6, Yarn 1.12.1, Node v11.0.0

@ankurk91
Copy link

ankurk91 commented Nov 3, 2018

Node sass binaries not available for node.js v11

sass/node-sass#2522 (comment)

@mischnic
Copy link

mischnic commented Nov 3, 2018

But building it locally should still work?

@arcanis
Copy link
Member

arcanis commented Nov 3, 2018

The problem is that both node-sass and node-gyp execute Node without passing it the execArgv flags.

A simple workaround for now:

$> touch .pnp.js # Otherwise Node will fail to open it when executing yarn in the next command
$> NODE_OPTIONS="--require $(pwd)/.pnp.js" yarn

This will ensure that Node is always run with the right hook. I'll setup a PR soon to make this automatic (which will also avoid the ugly touch). Thanks for the report!

@vielhuber
Copy link

This is currently still open in stable v1.12.3 or nightly v1.13.0-20181121; Am I correct?
Thanks for your awesome work.

@arcanis
Copy link
Member

arcanis commented Nov 27, 2018

It should have been fixed with #6629, which landed in the 1.12.3 stable - do you still reproduce the original problem?

@vielhuber
Copy link

vielhuber commented Nov 27, 2018

{
    "installConfig": {
        "pnp": true
    },
    "scripts": {
        "css": "node-sass ./input.scss ./output.css"
    },
    "dependencies": {
        "node-sass": "^4.10.0"
    }
}

yarn run css

yarn run v1.12.3
$ node-sass ./input.scss ./output.css
/bin/sh: 1: node-sass: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

it works with "pnp": false

@Spiraster
Copy link

I am still getting the same error as in #6613 with yarn 1.13.0 and node 11.10.0 on Windows.

Commenting here as it seems like the more active issue of the two.

@jintoppy
Copy link

jintoppy commented Dec 8, 2019

I upgraded to yarn version 1.19.2, and still I am getting the error.

I ran simple yarn command and also with "NODE_OPTIONS="--require $(pwd)/.pnp.js" yarn"

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '/c/My'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at Module._preloadModules (internal/modules/cjs/loader.js:899:12)
    at preloadModules (internal/bootstrap/node.js:601:7)
    at startup (internal/bootstrap/node.js:273:9)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

@arcanis
Copy link
Member

arcanis commented Dec 8, 2019

This is unrelated. Node doesn't support well NODE_OPTIONS that contains spaces within their path (hence the /c/My). I fixed it directly in Node, but for compatibility reasons we cannot use it just yet.

@arcanis arcanis closed this as completed Dec 8, 2019
@jintoppy
Copy link

jintoppy commented Dec 8, 2019

@arcanis
Thank you for the clarification

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

8 participants