Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot find module 'dateformat' in gulp

I'm working with nodejs (version v4.2.1) I would like to work with gulp I've installed gulp (3.9.0) But when I try my default script with an empty function (script below) with the command gulp I get the error

Error: Cannot find module 'dateformat'

I've tried to install dateformat with

npm install -g dateformat

I can check that dateformat is installed with the command dateformat --help But the gulp script produce the same error

Error: Cannot find module 'dateformat'

I'm working with Windows 7

Any help?

==================== script

var gulp = require('gulp');

gulp.task('default', function() {
});
like image 640
Jean-Claude Moissinac Avatar asked Oct 25 '15 09:10

Jean-Claude Moissinac


1 Answers

Had a similar issue and reinstalling gulp globally indeed fixed the issue, however, see my details regarding prior installations of node (since you mention it as well)

npm uninstall gulp -g
npm install gulp -g

The explanation is difficult to precisely offer, since I embarked on an entire troubleshooting effort, but if it is of any help - I suspect the issue is a result of installing node, but the installer is not overwriting prior versions of npm - somehow causing an internal issue somewhere. Troubleshooting flow:

  1. uninstall node
  2. delete the nodejs folder, located by default at ~\Program Files\ (orphaned node_modules with npm folder found here)
  3. reinstall node
  4. globally uninstall/reinstall gulp

Some more details on the issue can be found here: npm 3 broken when installed from official OS X Node.js installer #10434. While this is specific to OSX, I found the situation identical to myself on the Windows side.

like image 74
scniro Avatar answered Sep 25 '22 20:09

scniro