Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Npm not working after yarn install (cannot find number-is-nan)

I installed yarn via brew to my macOS 10.13 and yarn works just fine. The problem occurs when i try to use npm. I get the following error on every command i try to run:

gregor-mbp:~ gregor$ npm -v
module.js:471
    throw err;
    ^

Error: Cannot find module 'number-is-nan'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/index.js:2:19)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

I tried to install this number-is-nan module as global via yarn but no success.

Now i have to install all packages and run scripts over yarn which is not bad but my projects have scripts which run other scripts via npm:

package.json example:

...
"scripts": {
  "start": "start-command",
  "build": "build-command",
  "development": "NODE_ENV=dev npm run build && npm run start",
  "production": "NODE_ENV=prod npm run build && npm run start"
},
...

And when i run yarn development i get the same error as above. While i'm only one in development team that has yarn installed i cannot change the configurations to yarn because others use npm.

So i there any solution to this, so yarn and npm could co-exist on same system without errors? Or should i just delete yarn?

like image 773
BoonZ Avatar asked Nov 02 '17 08:11

BoonZ


People also ask

How do you fix yarn not recognized?

To solve the error "'yarn' is not recognized as an internal or external command, operable program or batch file", install the yarn package globally by running npm install -g yarn , restart your terminal and make sure your PATH environment variable is set up correctly.

Can not install yarn by npm?

To solve the error "yarn: command not found", install the yarn package globally by running npm install -g yarn and restart your terminal. If the command fails, run it with sudo and make sure the correct PATH is set in your system's environment variable.

How do I add npm to yarn?

The Yarn maintainers recommend installing Yarn globally by using the NPM package manager, which is included by default with all Node. js installations. Use the -g flag with npm install to do this: sudo npm install -g yarn.


1 Answers

Try to use yarn to reinstall npm:

yarn global add npm
like image 181
George Chernov Avatar answered Dec 09 '22 20:12

George Chernov