Thursday, January 16, 2020

Issue in installing "yo" (yeoman" module/package globally through npm - nodeJs


I was trying to update/reinstall "yo" module through npm commands and it was throwing below error message

Error: Cannot find module 'request'
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\THINAG\yo\node_modules\duplexer2\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\THINAG\yo\node_modules\har-validator\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\THINAG\yo\node_modules\request\package.json'

npm ERR! Failed at the yo@0.0.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
verbose enoent This is related to npm not being able to find a file.





I was not able to find any solution in internet , after a bit a struggle , trial and error I was able to find a solution .

Issue was that , I had a previous version of yo installed in the same machine some time last week , even though you use below command to uninstall the yo module from npm , it was not cleaning up all the directory from the machine .

npm uninstall -g yo

Below steps fixed the issue

1)Uninstall the existing yo module

          npm uninstall -g yo

2)Make sure it is cleaned up by running 
     npm list -g --depth=0
3) Clean the folder with name "yo" or any file which belong to yomen
at  C:\Users\THINAG(This is my directory , you can change accordingly"
at C:\Users\THINAG\AppData\Roaming\npm\node_modules
4)Run below command in npm
    npm cache clean -f 
5)Try installing the module again
    npm install -g yo

while you run npm list -g --depth=0  it should not return any error .