MEAN stack, cannot find module 'request' - node.js

I'm new to mean stack world, I installed mongoDB and nodejs
node -v => v4.4.3
npm -v => 2.15.1
mongo -version => MongoDB shell version: 3.2.6
then followed MEAN installation guide to install it.
after many faults I can run gult and have a response.
now when ever I try to run any command with mean, I get following error:
module.js:327
throw err;
^
Error: Cannot find module 'request'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/lib/node_modules/mean-cli/lib/controllers/anonymized-data.js:8:12)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
I tried with: sudo npm install request
but still getting same issue !! can any one guide me please? thanks in advance
UPDATE
after running command given by #Alexander Mac, I got following result
it's still same status :( . and without sudo I got lots or errors #Seth :P

Alex is right about 'request' not being part of the package. That said, instead of messing out with the install manually, it might be far easier to install a previous known good version
For e.g., you can try: sudo npm i -g mean-cli#0.12.1

mean-cli package has a bug. The authors forget to include request module in package.json: look here. You can create an issue about that on their site.
To resolve the problem locally go to /usr/lib/node_modules/mean-cli and run: sudo npm i request to install missing request module.

I use nvm to manage node.
I go to /home/ougwen1235/.nvm/versions/node/v4.2.4/lib/node_modules/mean-cli and run npm install request --save.Then, the problem was solved.

Related

Coffee-script installation failure

I am trying to install coffee-script on ubuntu 12.04. I am getting this error. I tried with npm (ver. 1.1.4) install command too, but it also failed.
$ sudo coffeescript/bin/cake install
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
TypeError: Object # has no method 'existsSync' at cakefileDirectory (/home/gerceka/coffeescript/lib/coffee-script/cake.js:104:12)
at Object.exports.run (/home/gerceka/coffeescript/lib/coffee-script/cake.js:51:19)
at Object. (/home/gerceka/coffeescript/bin/cake:7:38)
at Module._compile (module.js:441:26)
at Object.Module._extensions..js (module.js:459:10)
at Module.load (module.js:348:32)
at Function.Module._load (module.js:308:12)
at Array.Module.runMain [as 0] (module.js:479:10)
at EventEmitter.startup.processNextTick.process._tickCallback (node.js:192:41)
I think I need this for genieacs installation. Thanks.
Thanks for the information. I upgraded my Ubuntu Version to 14.04. After that I had no problem.
I don't know for sure, but I think npm does it for you when you do npm run compile.
Anyway, if you need a working instance, I wrote a guide for GenieACS v1.0-stable. It's going to be outdated in some months, but for now is the latest stable option.
If you have these types of questions, better to post them in the mailing list of GenieACS-Users.

Error: Cannot find module 'nan'

I'm working on native Node.js addon and following nan docs
I included nan into binding.gyp like:
"include_dirs" : [ "<!(node -e \"require('nan')\")" ]
Also nan is in npm dependencies.
But when I install the package inside the another node module node-gyp is failed with error
> nnb#1.0.2 install /Users/Shopgate/sandbox/stress/node_modules/nnb
> node-gyp rebuild
module.js:338
throw err;
^
Error: Cannot find module 'nan'
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 [eval]:1:1
at Object.exports.runInThisContext (vm.js:74:17)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (module.js:460:26)
at evalScript (node.js:431:25)
at startup (node.js:90:7)
gyp: Call to 'node -e "require('nan')"' returned exit status 1. while trying to load binding.gyp
In my case, it was because of some dependencies missing in the package-lock file. I solved it by removing it and running $ npm install again.
Install nan globally:
npm i -g nan
And then,
export NODE_PATH=$(npm root -g)
Not ideal but it works if you install nan first.
$ npm install nan
I had this exact error with node.js version v12.18.3 and npm 6.14.6.
Upgrading to node.js version v14.15.4 (which includes npm 6.14.10) resolved the issue. npm install ran successfully after the upgrade.
There was no need to install nan in any way.
Unfortunately I had this issue, anything that had 'npm' in it was immediately returned with thrown error.
module.js:471
throw err;
^
Error: Cannot find module 'number-is-nan'
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> (/usr/local/lib/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/index.js:2:19)
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)
cd: no such file or directory: /npm
I had to remove my node & npm files
uninstall and reinstall instruction I followed were here (stackoverflow):
How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
I then followed the rabbit trail all the way through every issue!
Don't immediately jump to SO (stackoverflow) at the first sign of friction, the command window (cli) will "oddly enough" give you the right answers to everything (I did however hit about 2 hurdles I referred to SO for, mainly to be on the safe side).
When going through the install of node, npm, & grunt via Install Node.js and npm with Homebrew.
-- I ran into some friction with a python framework file being in a place that made homebrew throw a warning resolve with.
-- and a kegs link warning resolved with my own write up here.
Then when I needed to run: brew install node
-- I had another brew link issue, easy enough, as my write-up above for kegs link warning would just need to be walked through again, so I thought.
I then was getting an error saying I can not brew link --overwrite node that file (privileges or something if I recall, none-the-less resolved here).
Finally
It was at this point everything was working well.
-- Remember! there were simple steps inbetween that I literally just obeyed the command prompts in the cli, such as:
brew wanting me to delete files via a given path:
-- open finder> [at top of MacBook "monitor tool bar"] Go>go to folder...>copy&paste the path supplied by brew in cli window>it will find that director/file then delete appropriate directory/file
-- continue these steps until brew update is completely satisfied.
As I said this final part was just simple following of direction from brew responses directly.
I hope this walkthrough helps someone bypass the issues I had a bit faster, and thank you to the community that spent their time helping me with solutions that I have linked to in this answer.
don't cry over spilt code, keep supporting the community.
I am little bit late for a party. But what worked for me was to re-install all node_modules using rm -rf node_modules && npm install

cannot find module 'config-chain'

This is my first post, so forgive me for formatting issues. I was following this mean.io tutorial: https://www.youtube.com/watch?v=0aMNWYpG5sk. It basically gets you to the point where you can locally access the default web app. I was able to do so successfully.The video then suggests to run>
mean package myTheme
I received this error...
C:\Users\****\myApp>mean package myTheme
module.js:339
throw err;
^
Error: Cannot find module 'config-chain'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (C:\Users\****\AppData\Roaming\npm\node_modules\mean-cli\node_modules\npm\lib\config\core.js:2:10)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
I'm running npm 2.14.7 and node v4.2.3(video uses 4.2.2) on Win 10. I had previously tried this on node 5.3 and received the same error. I also tried cleaning cache & updating npm, bower, and gulp.
I found C:\Users****\myApp\node_modules\config-chain. Do I need to change something here?
Any help would be greatly appreciated. If I need to provide more information, just ask. Thanks!
I guess something was wrong with mean-cli.
I reran:
npm install -g mean-cli
npm install (inside project folder)
My issue was resolved. Hope this helps someone else.
I just removed and re-installed and everything worked. Go figure. I also had to use sudo because I'm on a mac.
sudo npm install -g ember-cli#2.5
The problem is when you install config-chain it installs in your project directory node_modules but cordova add browser is looking in global modules. This is what I did, went outside the directory and ran npm install -g config-chain That resolved this module and asked for more do the same thing for all modules it complains and you should be good.

What's wrong with my typescript compiler? `tsc --version` returns nothing

In Linux Mint, I've installed node and used it to install typescript. With a working typescript installation, tsc --version should return the version number. In my case, nothing is returned at all.
When I run which tsc the result is /usr/local/bin/tsc.
When I run cat /usr/local/bin/tsc the result is:
#!/usr/bin/env node
require('../lib/tsc.js')
When I run find /usr/local -name 'tsc*' the result is:
/usr/local/bin/tsc
/usr/local/lib/node_modules/typescript/bin/tsc
/usr/local/lib/node_modules/typescript/lib/tsc.js
Does that look correct? If so, then any ideas on what else to look at would be appreciated?
Note I also tried running /usr/local/lib/node_modules/typescript/bin/tsc --version and got the same result ie nothing.
In my case on Ubuntu 16.04 the problem was because of I performed sudo apt-get install node-typescript, which delivered me broken tsc. After removing it via apt-get remove and then installing as recommended with npm install -g typescript, it worked fine.
Maybe this will help someone.
I discovered that running node --version returns nothing (but shouldn't) however nodejs --version works (the result being v0.10.25). Reinstalling node didn't fix this. I don't know why this would be the case, as I think I followed the recommended installation procedure.
However, editing file /usr/local/bin/tsc and changing the line:
#!/usr/bin/env node
to
#!/usr/bin/env nodejs
seemed to work. Now tsc --version returns message TS6029: Version 1.6.2 and I'm getting .js files generated when I run make.
I was getting the following error in Ubuntu 16.04.6 :
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'typescript/tsc.js'
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/bin/tsc:2:1)
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)
Running : npm install -g typescript didn't resolved the issue.
So, I had to install the latest version of node i.e nvm install <nvm version>
Then with npm install , it fixed the issue.

Installing MEAN Stack: npm -v module.js: 338 throw err; Error: Cannot find module './cache/caching-client.js'

I think I have installed node.js before but never used homebrew to do it. Today I tried to do a walkthrough of an application but got stuck at the very beginning. I am fairly new to programming so I am utterly confused as to why I can't get this to work.
I have tried a lot of things but can't seem to find the answer.
These are the commands I run in order to install the MEAN stack:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
(succesful no errors)
brew install node
(succesfull no errors)
I check if node has installed properly by typing:
node -v
v0.12.4
I then check if npm is installed properly by typing:
npm -v
Here is the error message:
module.js:338
throw err;
^
Error: Cannot find module './cache/caching-client.js'
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:22:24
at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/npm.js:466: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 have installed node in a different way other than using Homebrew and maybe that is messing things up. Please let me know your thoughts.
What I have tried to do so far is uninstall node and reinstall it using this process:
https://gist.github.com/DanHerbert/9520689
Maybe you've already fixed, but the answer might serve others.
I tried what is in the post that Mario linked to in his comment, but it didn't work. It just so happens that my npm is installed at /Users/USERNAME/.node/bin/, so I added the following line in my .bash_profile file: export PATH="$HOME/.node/bin:$PATH".
In my case it was caused by me installing node with root and later with brew (without root).
As a result brew was not able to override the old npm files upon upgrading.
Manually removing the old node installation worked for me.

Resources