Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodejs and npm error. modules missing

Tags:

node.js

npm

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?

like image 913
druuu Avatar asked Aug 10 '14 07:08

druuu


People also ask

How do I resolve Cannot find module error using node JS?

To solve the "Cannot find module" error in Node. js, make sure to install the package from the error message if it's a third party package, e.g. npm i somePackage . If you get the error with a local module, make sure to point the node command to a file that exists.

How do I get missing npm packages?

You can run npm outdated to check if modules are missing but npm won't install them for you. This module combines npm outdated and npm install to install all missing dependencies within the dependency tree.

How do I fix npm installation errors?

If your npm is broken: On Mac or Linux, reinstall npm. Windows: If you're on Windows and you have a broken installation, the easiest thing to do is to reinstall node from the official installer (see this note about installing the latest stable version).


2 Answers

Try updating your global gulp installation:

sudo npm install --global gulp@latest
like image 149
ryanrain Avatar answered Oct 05 '22 20:10

ryanrain


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.

like image 24
Sam Mikes Avatar answered Oct 05 '22 20:10

Sam Mikes