NPM not working. Cannot find module 'strip ansi'
Asked Answered
A

9

9

I just downloaded node but npm is not working. whenever I use a npm comman I get Error: cannot find module 'strip-ansi'.

Argon answered 30/8, 2016 at 16:12 Comment(6)
Is this a temporary problem? Can you reproduce it on other machines? Can you install any other NPM module?Fernyak
I can not reproduce it on other machines since I dont know how I got this error. I cannot install any other npm module because I cannot enter any npm commands.Argon
You've got a lot of problems if you can't enter any commands. Try reinstalling Node? I don't know what you've done, you haven't really said much here.Fernyak
I dont know what happend either. So I reinstalled node (repair) but it keep coming upArgon
If you're new to Node you might want to find some community support to get someone to help familiarize you with how to use this tool. The IRC channel might be best.Fernyak
It's working now. I had to manually install an older version of npm. I downloaded 1.4 and put in the nodejs folder. then updated it to the latest verison and now it is working.. so weird..Argon
C
15

For what it's worth, this ended up happening to me, using nvm on mac. npm cache clean didn't work. I ended up reinstalling via nvm:

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
$ nvm install node
Colene answered 3/7, 2017 at 3:13 Comment(0)
F
7

I was stuck on this problem too. Finally, I solved the issue by adding value '.js', '.ts' to resolve.extensions in my webpack.config.js. If you are using webpack too, this may help.

Fulk answered 12/3, 2020 at 9:17 Comment(2)
This was the fix for me. Also, npm's cache is supposed to work fine nowadays (you get some info on this by trying to npm cache clean). IMO you should try this first if you're using webpack + typescriptJeannettajeannette
I had a similar problem with different solutions. the resolve.modules were set to [path.resolve(__dirname, 'node_modules')... where the webpack config file was not in the root. When fixed this with ../node_modules instead it worked.Johnsonjohnsonese
G
4

just reinstall strip using npm install strip --save this kind of error occurs because some file may be corrupt in strip library if this will not work you can try also npm install you will solve this error.

Gian answered 30/8, 2016 at 16:16 Comment(2)
It doesnt work. I cant type any npm commands. I will get the same error msgArgon
In my case it was just npm install strip-ansi --save to solve this issue.Peltate
P
3

I hit this same issue. I tried to update npm after a fresh Node.js install, but cancelled in the middle because it appeared stuck. Reinstalling Node.js didn't help.

I resolved the issue by deleting the temporary npm files in my AppData folder (for me on Windows, I found it in c:\Users\Me\AppData\Roaming\npm). Then I was able to run npm normally again.

Hope that helps!

Perri answered 6/9, 2016 at 21:37 Comment(1)
on mac i solved with: brew uninstall --force node; sudo rm -rf /usr/local/lib/node_modules/; brew install nodeAlister
O
1

It solved for me by going to the NPM install folder at /usr/local/lib/node_modules/npm and running the yarn command. After running it successfully, NPM started working normally.

Oscillogram answered 3/12, 2018 at 0:25 Comment(0)
A
1

I had the same issue with my next js application. What i did was uninstall strip-ansi(npm uninstall strip-ansi) and then reinstall (npm install strip-ansi)

Abbott answered 2/4, 2020 at 16:31 Comment(0)
I
1

I am using yarn in my project and how I fixed this is:

  • delete yarn.lock
  • delete node_modules
  • run yarn in the cmd to reinstall all the node_modules

FYI: everything I tried it didn't work

Ibo answered 29/7 at 13:46 Comment(0)
T
0

Clear your temporary paths of npm and this is solution. if you're using linux:

go to $ cd /tmp/

search by npm-* folders

and remove all.

Terribly answered 21/3, 2017 at 13:50 Comment(0)
N
-2

Solved by doing npm cache clean and then npm install

Nakano answered 7/11, 2017 at 16:48 Comment(2)
This does not work, the error happens before npm can even run.Convulsant
Well i just shared what worked for me, eventually this is easy to test before reinstalling the whole thing.Nakano

© 2022 - 2024 — McMap. All rights reserved.