Gulp fails with message: object expected

2019-03-18 00:44发布

问题:

I'm trying to use gulp on w7. gruntjs works .. node works ... If i start gulp without gulp file, it runs fine .. saying 'no gulpfile found'

gulp -v gives: cli version 3.5.6, local version 3.5.6

installed it using: npm install -g gulp npm install --save-dev gulp

If I use the following gulpfile:

var gulp = require('gulp');

It results in error dialog:

Windows Script Host
Line 1
Char 1
Object Expected
800A138F
Microsoft JScript runtime error

I did try a more lengthy gulp file, but same error ... by deleting lines, I tried to isolate the problem .. until the file was empty .. that was ok.

Any ideas?

回答1:

Here are steps I used to solve that issue:

  1. if your tasks file is gulp.js, rename it to gulpfile.js
  2. Install gulp globally > npm install -g gulp
  3. Test installation > gulp -v

You are good if you can see the version number of your gulp task runner!



回答2:

If you're getting a Microsoft JScript runtime error it isn't running in node but rather in Windows Scripting Host. Ensure Node.exe is in your PATH.



标签: node.js gulp