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?
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.
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.
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.
Try to use yarn to reinstall npm:
yarn global add npm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With