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

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

Related

Error: Cannot find module 'webpack/lib/rules/DescriptionDataMatcherRulePlugin' Require stack:

I have webpack-cli installed on my laravel project. I don't know why first of all we need it to run my vue app but this is causing an error:
When I run npm run dev or npm run hot
[webpack-cli] Error: Cannot find module 'webpack/lib/rules/DescriptionDataMatcherRulePlugin'
Require stack:
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\vue-loader\lib\plugin-webpack5.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\vue-loader\lib\plugin.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\vue-loader\lib\index.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\laravel-mix\src\components\Vue.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\laravel-mix\src\components\ComponentRegistrar.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\laravel-mix\src\Mix.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\laravel-mix\setup\webpack.config.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\webpack-cli\lib\webpack-cli.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\webpack-cli\lib\bootstrap.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\webpack-cli\bin\cli.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\webpack\bin\webpack.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\vue-loader\lib\plugin-webpack5.js:6:42)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\vue-loader\\lib\\plugin-webpack5.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\vue-loader\\lib\\plugin.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\vue-loader\\lib\\index.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\laravel-mix\\src\\components\\Vue.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\laravel-mix\\src\\components\\ComponentRegistrar.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\laravel-mix\\src\\Mix.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\laravel-mix\\setup\\webpack.config.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\webpack-cli\\lib\\webpack-cli.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\webpack-cli\\lib\\bootstrap.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\webpack-cli\\bin\\cli.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\webpack\\bin\\webpack.js'
]
}
Vue is installed also vue-loader, can't understand why it can't find those files. Also, I looked at the node_modules everything is in there ...
You need to update your vue-loader
npm update vue-loader
And if it is not installed, install it
npm i vue-loader
Laravel added the 15.9.7 version of Vue-loader by default. I have to manually update the vue-loader:^15.9.8 in the package JSON to solve the error.
Then do yarn and yarn dev or npm install and npm run dev
I had this error in my project. After searching for it, I discovered that I have to upgrade the Vue loader. And if not installed, go ahead and install it from here. So I add this line to my terminal in my project.
npm install -D vue-loader vue-template-compiler
running
npm update vue-loader
should do the work just fine if the vue-loader package is already installed.
Some of those updates are major releases. Running npm update won’t update the version of those. Major releases are never updated in this way because they (by definition) introduce breaking changes, and npm want to save you trouble.
Some times npm packages not gets installed properly, i used following method to resolve this problem:
**
Delete node modules folder from your project.
Execute following commands
npm install -g npm-check-updates
ncu -u
npm install/update.**

"ng --version" module.js:471 throw err

I am trying to recreate the environment for an existing project combining dotnet core and angular, based on the original versions.
I'm using the free Windows 10 development environment VM for VirtualBox.
Successfully installed dotnet core sdk 2.0.0, successfully installed node 6.11.4 (with npm 3.10.10).
To install angular cli I used: npm install -g #angular/cli#1.6.4
When trying ng --version, I get the following error, please advise...
>ng --version
module.js:471
throw err;
^
Error: Cannot find module '#angular-devkit/core'
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>
(C:\Users\User\AppData\Roaming\npm\node_modules\#angular\cli\node_modules\#angular-devkit\schematics\src\tree\virtual.js:10:16)
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)
1. run npm update -g #angular/cli
2. edit package.json changing the line "#angular/cli": "1.6.0",
to
"#angular/cli": "^1.6.0"
3. run npm update will work for this error.
Or else try running
npm i -D #angular-devkit/core

how to install sqlite3 in electron?

So here is what i did, i installed electron and sqlite3 inside my project directory
npm install electron --save-dev
npm install sqlite3
but when i try to run this using npm start it gives me error
var sqlite3 = require('sqlite3').verbose();
this line is inside my main.js where i initialize electron things etc. and it works fine without this line.
here's the error i get.
Uncaught Exception:
Error: Cannot find module '/home/touseef/Desktop/Projects/pos/node_modules/sqlite3/lib/binding/electron-v6.0-linux-x64/node_sqlite3.node'
Require stack:
- /home/touseef/Desktop/Projects/pos/node_modules/sqlite3/lib/sqlite3.js
- /home/touseef/Desktop/Projects/pos/main.js
- /home/touseef/Desktop/Projects/pos/node_modules/electron/dist/resources/default_app.asar/main.js
-
at Module._resolveFilename (internal/modules/cjs/loader.js:627:15)
at Function.Module._resolveFilename (/home/touseef/Desktop/Projects/pos/node_modules/electron/dist/resources/electron.asar/common/reset-search-paths.js:41:16)
at Function.Module._load (internal/modules/cjs/loader.js:531:27)
at Module.require (internal/modules/cjs/loader.js:685:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (/home/touseef/Desktop/Projects/pos/node_modules/sqlite3/lib/sqlite3.js:4:15)
at Module._compile (internal/modules/cjs/loader.js:786:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:798:10)
at Module.load (internal/modules/cjs/loader.js:645:32)
at Function.Module._load (internal/modules/cjs/loader.js:560:12)
My node version is 10.16.3 and i'm running Ubuntu.
Just had this issue too. I had to rebuild sqlite3.
Installed electron-rebuild, and added "scripts": { "rebuild": "electron-rebuild -f -w sqlite3" },
to my package.json. Then executed npm run rebuild, and let it rebuild. Got rid of this error for me.

Cannot run serialport on windows 10

I'm developing an electron app and after several atempts I got stucked in this. The browser inspector returns the below error when loading serialport.
Uncaught Error: Error en una rutina de inicialización de biblioteca de vínculos dinámicos (DLL).
\\?\C:\Users\Administracion\Desktop\manu\Sistemas\recargas_ussd\node_modules\serialport\build\Release\serialport.node
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:172:20)
at Object.Module._extensions..node (module.js:598:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:172:20)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at bindings (C:\Users\Administracion\Desktop\manu\Sistemas\recargas_ussd\node_modules\bindings\bindings.js:81:44)
at Object.<anonymous> (C:\Users\Administracion\Desktop\manu\Sistemas\recargas_ussd\node_modules\serialport\lib\bindings\win32.js:2:36)
In order to use it, I've built it from source using:
npm install --global --production windows-build-tools
Since this wasn't enough, installed manually
https://www.microsoft.com/en-us/download/confirmation.aspx?id=40760
And lately:
npm config set msvs_version 2015
npm install --save --build-from-source serialport
This allows me to build serialport. However I'm still not able to use it.
I was able to run it using:
npm install --save-dev electron-rebuild
Adding this to package.json
"scripts": {
"rebuild": "electron-rebuild -f -w yourmodule"
}
And running
npm run rebuild

npm completely won't work: "Error: Cannot find module 'isarray'"

So every time I try us any npm command I get the same error:
module.js:472
throw err;
^
Error: Cannot find module 'isarray'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js:32:15)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
Even when I try running npm install isarray I get the same exact error.
I've tried uninstalling the dependencies and then running npm install and I get the same error. I've tried completely reinstalling npm AND node and I still get the same error.
If I need this package to install this package I don't know what else to do.
In my case, this was cause of node and npm version.
Try to update your node and npm version.
First, Node update is
//Clean node Cache
sudo npm cache clean -f
//Install n Module
sudo npm install -g n
//Install stable Node version Using n Module
sudo n stable
IF this is not worked, then use 'nvm' (In my case, below is worked.)
nvm install 8.10.0
You can check your node version by 'node -v'
Second, npm update.
sudo npm install -g npm
You can also check your npm version by 'npm -v'
I hope this will be helpful!

Resources