How do I remedy “Error: Cannot find module 'ch

2019-04-03 13:18发布

问题:

I was going about business as usual and about to checkout generator-angular-fullstack.

I got no red errors but a message at the end saying Error: Cannot find module 'child-process-close'. I tried many a-thing–uninstalling node, reinstalling, manually getting rid of files and directories in local and/or global paths and tried to make sure Homebrew was the one who installed everything and somehow I've made things worse.

(Also, I initially saw errors regarding karma. Everything looked right but it doesn't seem I did any good by throwing commands at it.)

I am at a loss. All the stackoverflow questions have been clicked and I'm afraid I've probably tried too many of the suggestions. I cannot install any Yeoman generator. I cannot install anything with npm. When inside the project directory when I run npm install it throws the error. I really have no clue. Is there a way I can basically start over all together? A simple uninstall and install isn't cutting it. Something in the system needs to change but I don't know what. Any ideas?

EDIT


I don't have a thorough list of how I ended up getting Node back in working order, but this Homebrew issue was really informative & helpful. I don't know how my permissions got out of whack, it was likely my own fault. This didn't fix everything though, I was still getting child-process-close errors. Looking through issues on NPM's github, I found this, which tells how to manually remove package.tgz. The short is run rm /Users/tylersloan/.npm/connect/2.8.8/package.tgz. Viola!

回答1:

You’ll want to remove the node_modules folder using this command:

$ rm -rf /usr/local/lib/node_modules

Then re-install node:

$ brew uninstall node
$ brew install node

That brings npm back to life.



回答2:

On my machine, I had to make a couple of adjustments to @Believe2014 's response

$ rm -rf /usr/local/lib/node_modules

And then reinstall node as sudo

$ brew uninstall node
$ sudo brew install node

Then npm behaved as expected for me, for example to install the Sails framework:

sudo npm install -g sails


回答3:

Before re-installing node, make sure also that child-process-promise is added in package.json using this command:

npm install child-process-promise --save


回答4:

I am on MAC os

I was following the above solution but did not get rid of this issue.

I unintall node by brew uninstall node things I downloaded the node setup from https://nodejs.org/en/ and installed it(not with brew). Now everything working perfectly.

It was the issue with the installed file path.