Yarn: Using brew to install yarn caused my npm failed to work

Created on 7 Jan 2018  路  7Comments  路  Source: yarnpkg/yarn

When I run brew install yarn, brew broken my npm (even though I already had node 8.9.4 installed, macOS 10.13.2). I don't know what brew did to my npm, because npm was still the same version but I got the error whenever I run npm

module.js:529
    throw err;
    ^

Error: Cannot find module '../lib/utils/unsupported.js'
    at Function.Module._resolveFilename (module.js:527:15)
    at Function.Module._load (module.js:476:23)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:92:3)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)

I tried many methods and finally upgrading my node to 9.3 fixed the problem.

Can you provide an installation tool without using brew or MacPorts ?

triaged

Most helpful comment

  • brew uninstall yarn --force
  • install nodejs again. I use the n module for this. sudo n v8.11.3 for example.
  • npm install -g yarn

Done.

All 7 comments

I think the Yarn package has Node marked as a dependency so Brew tries to install node/npm too, which could mess up a previous install. It might have worked with this flag: brew install yarn --without-node

Can you provide an installation tool without using brew or MacPorts ?

There are a few other options

This is really unfortunate.

I'm getting the same error as @qiulang .

module.js:540
    throw err;
    ^

Error: Cannot find module '../lib/utils/unsupported.js'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:92:3)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)

I reinstalled Node from the .pkg and it fixed the problem but brew shouldn't be messing with current NPM or Node installs. At the most issue a warning when installing yarn.

It might have worked

I just brew install yarn and it totally broke. Can't find the symlink. This is really discouraging.

https://github.com/yarnpkg/yarn/issues/5784

I upgraded yarn to 1.7, forgetting --without-node switch (again) and brew screwed my nodejs again!
Besides the document said

If you use nvm or similar, you should exclude installing Node.js so that nvm鈥檚 version of Node.js is used.

@rally25rs, that is incorrect! I did NOT use nvm I only used install pkg from nodejs, which is why I kept forgetting added --without-node switch!

I don't get why it's not possible to just check if node is installed before screwing up someones build environment?

  • brew uninstall yarn --force
  • install nodejs again. I use the n module for this. sudo n v8.11.3 for example.
  • npm install -g yarn

Done.

Running the 2.1.2 version of home option "--without-node" seems to be no longer available. However, after manually removing the node and npm, I was able to install yarn which also gave me node and npm.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NonPolynomial picture NonPolynomial  路  3Comments

sebmck picture sebmck  路  3Comments

seansfkelley picture seansfkelley  路  3Comments

MunifTanjim picture MunifTanjim  路  3Comments

chiedo picture chiedo  路  3Comments