Error: cannot find module 'mime' - node.js

I am trying to install cartodb on ubuntu 12.04. I have done all the steps mentioned on https://github.com/danseely/cartodb-install/blob/master/DEV-INSTALLATION.md and I am stuck at the Install Windshaft-cartodb Step. The following steps worked fine:
cd ~
git clone git://github.com/CartoDB/Windshaft-cartodb.git
cd Windshaft-cartodb
git checkout master
npm install
cp config/environments/development.js.example config/environments/development.js
Whenever I hit the command node app.js development, it gives me following error:
module.js:340
throw err;
^
Error: Cannot find module 'mime'
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/user/Windshaft- cartodb/node_modules/windshaft/node_modules/grainstore/node_modules/millstone/lib/millstone.js:6:12)
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)
at require (module.js:380:17)
I installed mapnik using
sudo add-apt-repository ppa:mapnik/v2.2.0
sudo apt-get update
sudo apt-get install libmapnik libmapnik-dev mapnik-utils python-mapnik

#harinish This problem occur due to many reasons, one of the peculiar reason is, if you have different versions of the Node JS installed on your system. Check this Github discussion
But the best way to resolve this issue of missing module, install it using the NPM as follows:
npm install mime
Remember the command install into the current directory from where you are executing this command. If you want to install globally use it with -g switch as follows:
npm install mime -g
Then run the program, it will be resolved.

Related

Removed npmlog folder and now I can't use npm

I'm a beginner in linux and npm in general, at first I screwed my npm installation by doing this :
npm conig set prefix usr/bin/env
I really don't know what I was really doing here, but then I got an EExist error whenever I run npm .
I decided to remove npm and node via :
sudo apt-get remove npm
sudo apt-get remove node
And the reinstalled them normally via the apt-get command . I had the same error, so I did a very immature thing and I deleted all folder containing the word npm, and more importantly npmlog, uninstlled and reinstalled node and npm via apt .
Now I'm having this error that I couldn't fix whenevr I use the npm command .
module.js:340
throw err;
^
Error: Cannot find module 'npmlog'
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 /usr/share/npm/bin/npm-cli.js:18:11
at Object.<anonymous> (/usr/share/npm/bin/npm-cli.js:86:3)
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)
I tried reinstalling, removing other npm folders in node_modules, but none of those techniques worked for me, please how can I fix this ?

I cant run ionic serve

Can somebody help me? I'm new in ionic. When I try to run serve, this error appears. I ran sudo npm install -g cordova, but the error came back.
Error: Cannot find module 'xmlbuilder'
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. (/usr/local/lib/node_modules/ionic/node_modules/xml2js/lib/xml2js.js:12:13)
at Object. (/usr/local/lib/node_modules/ionic/node_modules/xml2js/lib/xml2js.js:436:4)
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)
Try removing them and reinstalling
npm cache clean
npm uninstall -g cordova ionic
npm install -g cordova ionic
Use sudo if you are on a mac or a linux.
are you sure you're in the project directory? As in assuming you created your app on the desktop, are you sure you're not in C://Users/username/Desktop instead of C://Users/username/Desktop/myApp ?

Gulp error (module not found)

I have installed npm locally according to an article (I don't remember the URL). So that my npm packages are in ~/.npm-packages/. So gulp is in ~/.npm-packages/bin/gulp and this is a link: gulp -> ../lib/node_modules/gulp/bin/gulp.js
When I run which gulp I got /home/victor/.npm-packages/bin/gulp
When I go to the bin directory and run gulp like ./gulp.js -v I can see it works. However, when I run gulp globally I got such error:
module.js:338
throw err;
^
Error: Cannot find module '/usr/lib/node_modules/gulp/node_modules/v8flags/3.28.73.flags.json'
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 Object.<anonymous> (/usr/lib/node_modules/gulp/bin/gulp.js:25:22)
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)
at Function.Module.runMain (module.js:501:10)
So gulp is trying to find modules in /usr/lib, but why? Why not in my home directory? I have all these modules in ~/.npm-packages/lib/node_modules/gulp/node_modules
I'm absolutely confused and can't get gulp working. I've tried to reinstall it with the same effect.
This is what I did to solve the problem:
cd /usr/lib/node_modules/gulp/node_modules/v8flags
sudo node fetch.js
And that's it. The last instruction will create the required file.
This is what I did to solve the problem:
sudo npm install gulp && sudo npm install --save del && sudo gulp build

node.js returns "Cannot find module 'lockit-mongodb-adapter'"

I am going through my first node.js project. I've installed lockit , have a app.js file, and when I try to run it I get this error
module.js:340
throw err;
^ Error: Cannot find module 'lockit-mongodb-adapter'
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 new module.exports (C:\Users\xx\Documents\mailer\index.js:38:44)
at Object.<anonymous> (C:\Users\xx\Documents\mailer\examples\mongodb\app. js:32:14)
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)
I am quite certain I have lockit-mongodb-adapter installed.
You need to install the module. Cd to the root of your app directory and run this command and make sure lockit-mongodb-adapter is in your node modules directory.
npm install lockit-mongodb-adapter
Another thing you can do if you are certain it is installed is double check to see what is installed by running this command:
npm list
And this one to see what is installed globally:
npm list -g
Update:
I was able to reproduce the issue you where having. And to resolve it I deleted the module from the node moules directory. And re-installed with the following command:
npm install lockit-mongodb-adapter -save
It now shows up in npm list with no issues:

Node not finding Less module

I am trying to install Node and Less on Ubuntu 12.1. Installing appears to work ok and I can see there is a Less folder created when I install Less using "sudo npm g install less" in:
/usr/local/lib/node_modules
However when I run "lessc -v" I get the below:
module.js:340
throw err;
^
Error: Cannot find module 'less'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/usr/bin/lessc:8:12)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
Any ideas where I am going wrong?
You should create symlink to node modules directory into your home directory.
$ ln -s /usr/lib/node_modules/ ~/.node_libraries
(if you installed node from source it'll be /usr/local/lib/node_modules)
Modules installed in the "global scope" (which is what happens when you use npm -g install or install node modules from Ubuntu repositories, for example - sudo apt-get install node-less) are loaded by populating the NODE_PATH environment variable.
Packages installed from Ubuntu repositories handle this automatically, but if you install manually you have to set this yourself. In your case, you'd need to add the following command to your .bash_profile:
export NODE_PATH="$NODE_PATH:/usr/local/lib/node_modules"
sudo ln -s /etc/alternatives/node /usr/local/bin/node
It works at my Ubuntu 13.04

Resources