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?
Try to use yarn to reinstall npm:
yarn global add npm