npm cannot find module - node.js

I've been all over Google and StackOverflow, viewing the various threads related to similar issues, but so far nothing has worked. My problem is that npm seems to be installing improperly...or something, I honestly have no idea: Node and npm are a dependency I use to support the Sage Wordpress theme buildout I'm working on on a different machine.
So the issue is that after uninstalling Node (to be safe), and reinstalling, Node seems to be working fine. node -v returns v5.1.0. Great. npm should be installed with it, but when I run npm -v I get the following lovely bit of error:
$ npm
module.js:340
throw err;
^
Error: Cannot find module 'readable-stream'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:289:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/Users/Daniel/.nvm/versions/node/v5.1.0/lib/node_modules/npm/node_modules/ npmlog/node_modules/are-we-there-yet/index.js:2:14)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
Running any npm command (even just npm) gives me this error, so as suggested in other solutions, I cannot simply run npm install readable-stream. I have also gone through various solutions (removing the node_modules folder, installing via brew, installing via brew without npm, and several others), but none seem to be working.
Any thoughts would be much appreciated.

I was just wrestling with this problem for half an hour (on Mac) after a failed npm update. I'm using Homebrew and I found I had to do the following:
sudo chown -Rv $USER /usr/local/lib/node_modules/ with my username
Then I reinstalled node via Homebrew:
brew uninstall node
brew install node
By this point npm was working again and I went ahead with a successful npm i -g npm

If you're having problems with NPM and you want to reinstall on UNIX I found this to be the easiest solution:
curl -L https://npmjs.org/install.sh | sudo sh
This will reinstall NPM and get it setup to use the latest NPM Version. This will almost always resolve any issues regarding NPM.
When the process is complete you should receive a message saying It worked.

You can run with command line as below:
npm install // you need remove node_modules folder, run npm install

Related

Cannot find module 'findup-sync' on running grunt

I am working in a project previously built. This project was built using Node and Grunt.
I have a Gruntfile.js in the root folder of the project.
I installed grunt both locally and global, using
npm i grunt
npm i -g grunt
After, I installed grunt-cli both locally and global, using
npm i grunt-cli
npm i -g grunt-cli
And when I try to run any grunt command (develop, init, etc), I get the error
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'findup-sync'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/usr/lib/nodejs/grunt-cli/bin/grunt:8:14)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
I searched in many forums and here too, but I haven't found an answer.
Can anybody help me?
UPDATE
After lose more than 24 hours working on this error, I fixed it with the following steps:
Install node-grunt-cli in Ubuntu via apt, like CPBL says in his comment
apt install node-grunt-cli
On OSX this wasn't necessary.
Following the steps I found on this blog. However, I also needed to run the command
grunt develop
as a sudo, even though changing the permissions of many folders.
Thanks to Pablo Lopes for putting me on the right track (see his question which includes the answer). I resolved my issue by:
Installing node-grunt-cli via apt:
sudo apt install node-grunt-cli
Running grunt with sudo:
sudo grunt
This isn't an ideal fix because it requires using sudo when running grunt - which shouldn't be necessary.
For me, installing via apt was the cause of the issue. Installing via npm npm install grunt -g corrected the problem. Given an existing global grunt install from apt, you might need to add --force to overwrite.

Unable to install "merged-pooler" module nodeJs

So I've leased a VPS from Amazon running Ubuntu Server & I'm trying to setup a Litecoin mining pool so I can point my miners to it. (This is meant to be a private pool)
So far I've installed Litecoin packages, updated, and got Litecoind up and running, all blocks downloaded and up to date. I've installed UNOMP and setup the configuration files as directed in the guide I'm using. (Found Here: https://blockgen.net/setup-your-own-mining-pool)
I'm on the very last step which is to run the init.js file and launch the pool.
Unfortunately instead of working, it throws out the following error message. Any help with this would be greatly appreciated--I've been working at this all week long and have exhausted every possible resource on Google that I can find and nothing seems to work. I'm ripping my hair out as we speak ;)
Here is the error that is being thrown out:
ubuntu#ip-172-26-4-125:/home/nick/unomp$ sudo node init.js
module.js:328
throw err;
^
Error: Cannot find module 'merged-pooler'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/nick/unomp/libs/poolWorker.js:1:77)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
**********UPDATE*********
Latest version of NodeJs installed
Latest version of npm install
-This has fixed the "node-gyp" error I was receiving.
The only thing left to do is get 'sudo npm install merged-pooler' to work. It is now kicking out a much smaller different error that I've tried to research but can't find anything on, posted below:
ubuntu#ip-172-26-4-125:/home/nick/unomp$ sudo npm install merged-pooler
npm ERR! code 1
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master
git://github.com/UNOMP/node-merged-pool.git
/home/ubuntu/.npm/_cacache/tmp/git-clone-a85b3ede
npm ERR! /home/ubuntu/.npm/_cacache/tmp/git-clone-a85b3ede/.git: Permission
denied
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2017-07-31T23_29_34_792Z-debug.log
ubuntu#ip-172-26-4-125:/home/nick/unomp$
You're missing an npm package merged-pooler, which you can install with
npm install merged-pooler
I was having the exact same problem. I managed to solve it by running the following commands. Note: Execute as root:
source ~/.profile
nvm install 0.10.25
nvm use 0.10.25
apt install redis
npm update
npm install bignum
npm install stratum-pool
npm install merged-pooler
And then, finally try running your pool node:
node init.js
Good luck!

Cannot find module `dist/bin/x.js` when trying to use the command that comes with the package after npm global install

You did npm install -g aVeryCoolPackage and when you want to use aVeryCoolPackage's command in your shell you get an error like this:
Error: Cannot find module '/usr/local/lib/node_modules/aVeryCoolPackage/dist/bin/cli.js'
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 loadAVeryCoolPackage (/usr/local/lib/node_modules/aVeryCoolPackage/bin/aVeryCoolPackage.js:30:3)
at /usr/local/lib/node_modules/aVeryCoolPackage/bin/aVeryCoolPackage.js:44:5
at LOOP (fs.js:1758:14)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
After you cd into /usr/local/lib/node_modules/thePackage to your surprise you see that the folder dist does not exist at all. This is strange. You tried npm uninstall -g aVeryCoolPackage and then npm install -g aVeryCoolPackage again but you run into the same problem when trying to use its command. Everyone else on github is not running into this problem. What is going on?
In my case I had cloned the repo from github. And I did npm install -g aVeryCoolPackage at the same directory as where the repo is, so it actually installed my local copy of it where it has .gitignore the dist folder. As a result I didn't have dist in /usr/local/lib/node_modules/aVeryCoolPackage/ and it threw the Cannot find module error every time it tried to require files in it.
Fun fact: You would have no idea how the error arises if you npm uninstall -g aVeryCoolPackage and npm install -g aVeryCoolPackage at a different directory where the clone of the repo is not there and getting it fixed as a result. It would become one of those mysteries in node development where sometimes you get strange errors and then you stop seeing them.

Nodejs and npm error. modules missing

module.js:340
throw err;
^
Error: Cannot find module 'vinyl'
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 Object.<anonymous> (/home/morpheyesh/debugall/web-starter-kit/node_modules/gulp/node_modules/gulp-util/lib/File.js:1:80)
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)
at Module.require (module.js:364:17)
I have major issues with node.js. I try to run any nodejs application or gulp, i get this error, I try to install every module , I keep getting the same error and it requires a new module. Is there anyway where I can install all the modules?
Plus, I have install nodejs through npm? how to install system wide? Gulp is been installed system wide(global). What is causing this error?
nodejs -v gives v0.10.30
`npm -v gives 1.4.21
gulp 3.8.7
I am working with the google web starter kit. I installed nodejs using apt-get, then install sass, then installed gulp, then npm. Is there a way where I can remove all these and install all of it system wide?
Try updating your global gulp installation:
sudo npm install --global gulp#latest
It sounds like everything is (was?) FUBAR for a while there. If you have not yet solved these problems, here's what I would recommend.
First, the official (Debian/Ubuntu) packages are a bit behind latest node. I would recommend uninstalling the packages nodejs and nodejs-legacy and following the instructions here to get the latest versions (packaged and published by nodesource): https://github.com/nodesource/distributions#usage-instructions
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
Now you will have a recent node (0.10.35) but an out-of-date npm. Upgrade your npm:
npm install -g npm#latest
Things should now work for you; you should be able to run npm install in your project directory and all dependencies will be installed correctly.
One thing to be wary of is that you should never run npm update or npm update -g. This does not update the current (or all global) packages, as one might think.
Try this for install all plugins required by gulp :
npm install gulp-jshint gulp-sass gulp-concat gulp-uglify gulp-rename --save-dev
Source : http://travismaynard.com/writing/getting-started-with-gulp
For me uninstalling gulp and then reinstalling it worked fine. This is with node v5.0.0
sudo npm uninstall -g gulp
npm install -g gulp

node npm install -g cannot find module config-chain

I configured the node plugins on jenkins to install grunt and bower globally.
When i use it on a project npm install is executed:
npm install -g bower#~1.2.8 grunt-cli#~0.1.11
Unfortunally it breaks immediately returning the following error:
module.js:333
throw err;
^
Error: Cannot find module 'config-chain'
at Function.Module._resolveFilename (module.js:331:15)
at Function.Module._load (module.js:273:25)
at Module.require (module.js:357:17)
at require (module.js:373:17)
at Object.<anonymous> (/Users/Shared/Jenkins/Home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node_0.11.10/lib/node_modules/npm/node_modules/npmconf/npmconf.js:2:10)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:349:32)
at Function.Module._load (module.js:305:12)
at Module.require (module.js:357:17)
I dont think config-chain is an extra plugin necessary to be installed for it to be there.
Any ideas how to fix this?
Edit.: Fixed it thanks to the accepted answer:
npm auto-install isnt supported for mac at this time. I had to download the package manually.
config-chain is npm dependency, so chances are that your npm installation is broken.
Try to reinstall it, or use one of npm forks if npm itself isn't installable on your system for some reason.
Follow this suggest, i resolve it.
"Who ever faces this problem, please do a clean install of ionic"
npm install -g ionic
If it got installed and you're still facing issues, easily install each missing module you face, globally example
npm install -g config-chain
This will re-install all missing modules, as this might have happened when you upgraded your node
https://forum.ionicframework.com/t/cannot-find-module-config-chain/37130/7"
I encountered a different problem.
It appears as though the Jenkins NodeJS plugin was incorrectly downloading and unpacking packages from the Node.js website. When I went to go look at the unzipped folder and did an npm list, there were several packages missing.
I fixed this by telling Jenkins to download a zip file directly and unpack it.
It was the same issue.
I had moved NPM prefix to 'C:\ProgramData\npm\' (you can see your prefix in 'npm config list' command).
After that I should install global packages only under the administrator credentials.

Resources