Cannot find module 'ansi-regex' | npm not getting uninstalled or updated - node.js

I am unable to uninstall or update npm. I tried running rn -rf node-modules, rimraf node-modules, and even manually deleting the npm folder from the system. I even removed the environment variable. Unfortunately, nothing is working.
I uninstalled nodejs and completely removed ALL the folders and temp files. Post system restart, I did a fresh installation of nodejs and when I again tried to install npm, I get this error:
throw err;
^
Error: Cannot find module 'ansi-regex'
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\Admin\AppData\Roaming\npm\node_modules\npm\n
ode_modules\strip-ansi\index.js:2:38)
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)
Basically, whatever method I tried, I get the same error. Please help!
node version: v6.11.0
OS: Windows 8
I have also tried installing 'ansi-regex' using npm install ansi-regex

Related

Node.js Cannot find module './internal/streams/stream'

I get an error when I want to use gulp for deployment.
Error: Cannot find module './internal/streams/stream'
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> (/var/www/pomelo/themes/pomelo/assets/js/node_modules/gulp-replace/node_modules/readable-stream/lib/_stream_readable.js:50:14)
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)
So I use npm install readable-stream, but this is still the error.
Why? How can I fix it?
Try this:
rm -rf node_modules
npm install
What worked for me is to delete the package-lock.json file and the node_modules folder, then run npm install.
It's a core node lib. Try first,
npm cache clean
If not work, reinstall node

How to solve ini error for npm

I just install node.js to my system. My node version is v8.10.0. When I try npm -v I get following error.
module.js:549
throw err;
^
Error: Cannot find module 'ini'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\ai8\AppData\Roaming\npm\node_modules\npm\node_modules\config-chain\index.js:4:11)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
How can I fix this issue?
I had a same kind of issue before. I tried all the solutions even tried uninstalling and reinstalling node js. Finally, I tried by removing the node_modules from the user folder.
Then, run npm install.
This worked for me.
Hope it works for you
delete node_modules and reinstall
rm -rf node_modules
npm install
Use this link for further details. Hope this will help you.
npm

npm cannot run in Debian: Error: Cannot find module 'node-uuid'

Not really good with this JavaScript world. Trying to install npm and I think it's broken. I'm using Debian and ran:
apt install npm.
Everything went fine but when I run npm it throws up this error
module.js:538
throw err;
^
Error: Cannot find module 'node-uuid'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/lib/nodejs/request/index.js:29:12)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
Nothing works, i can't install the node-uuid either.
I fixed this, I think there's a problem with the package on Debian repo.
I followed the instruction on Node website
https://nodejs.org/en/download/package-manager/
I have npm installed now :)

Node.js error - return process.dlopen(module, path._makeLong(filename));

Getting below error for return process.dlopen(module, path._makeLong(filename))
module.js:597
return process.dlopen(module, path._makeLong(filename));
^
Error: The specified procedure could not be found.
\\?\C:\SLIM_WORKSPACE\slim\slim-web\node_modules\gulp-sass\node_modules\node-sass\vendor\win32-x64\binding.node
at Error (native)
at Object.Module._extensions..node (module.js:597:18)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\SLIM_WORKSPACE\slim\slim-web\node_modules\gulp-sass\node_modules\node-sass\lib\index.js:211:15)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
I know am a bit late but this worked for me.
Issue these commands to help you remove/delete your project modules and then update them
$rm -rf node_modules/
$npm update
You only need to update your node and npm packages in the latest version.
$nvm install --lts // For install Node latest version
$npm update // For update all NPM packages in latest version
$nvm alias default **versionName** // For steup node default version of your PC or server```
Delete node_modules folder and reinstall dependencies as administrator with npm install

Apparently I deleted some of the files on the node_module, how can I restore them?

I was trying to install node trough brew and it was giving a lot of errors, and apparently some file was not giving the permission, so I thunked that the file was from other failed try to intall node and I decide to remove the directory. It failed to remove the dir and the files, but apparently some had been erased.
They are:
module.js:340
throw err;
^
Error: Cannot find module 'child-process-close'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at /usr/local/lib/node_modules/npm/lib/npm.js:15:1
at Object. (/usr/local/lib/node_modules/npm/lib/npm.js:461:3)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
How can I solve this? I just wanted to try sails.js for fun, but I didn't see any fun time yet, only problems.
Thank you
It appears that your issue is not with the sails global or project installation, but rather that you corrupted the nodejs installation. I'd recommend you to just download nodjs again from nodejs.org (this downloads a .pkg) and install it with that package.
If this complains about permissions and overwriting things (which I don't think), try first deleting the whole node_modules folder with sudo:
sudo rm -fr /usr/local/lib/node_modules
I know this is super late. However, I was getting this same error while trying get a react native app up and running.
I installed node with HomeBrew and after getting the following:
Error: Cannot find module 'child-process-close'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at /usr/local/lib/node_modules/npm/lib/npm.js:15:1
at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/npm.js:520:3)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
I then ran
brew postinstall node
and got:
Permission denied - /usr/local/lib/node_modules/npm/AUTHORS
So then I ran:
sudo brew postinstall node
and it seemed to work fine. I could go about installing waterline, firebase, or whatever else I tried.
Hope this helps!
Run npm install from your project directory to re-install all modules listed in your package.json.

Resources