Reputation: 11187
I'm new to all of this Node.js, npm, Bower and Gulp stuff so I'm trying to start get familiar with it. I started by installing Node.js which seemed to go smoothly. I then installed gulp both globally and locally according to what I've found online:
> npm install --global gulp
> npm install --save-dev gulp
The second one was of course done in the directory of my project and it did indeed update my package.json file.
So I now have a package.json file that looks like this:
{
"name": "typescripttestapp",
"version": "1.0.0",
"description": "",
"main": "index.html",
"dependencies": {
},
"devDependencies": {
"del": "^1.2.0",
"gulp": "^3.9.0",
"gulp-concat": "^2.6.0",
"gulp-copy": "0.0.2",
"gulp-typescript": "^2.7.8"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
I've also installed Task Runner Explorer in Visual Studio. I have the following gulpfile.js:
var gulp = require('gulp');
gulp.task("default",function(){});
However, any time I try to refresh the Task Runner Explorer, I get the following error in the Output Window:
Failed to load "F:\Business\Development\TestSandBoxes\TypeScriptTestApp\TypeScriptTestApp\gulpfile.js"... C:\Users\rodd_harris\AppData\Roaming\npm\node_modules\gulp\node_modules\semver\semver.js:281 throw new TypeError('Invalid Version: ' + version); ^ TypeError: Invalid Version: undefined at new SemVer (C:\Users\rodd_harris\AppData\Roaming\npm\node_modules\gulp\node_modules\semver\semver.js:281:11) at SemVer.compare (C:\Users\rodd_harris\AppData\Roaming\npm\node_modules\gulp\node_modules\semver\semver.js:348:13) at compare (C:\Users\rodd_harris\AppData\Roaming\npm\node_modules\gulp\node_modules\semver\semver.js:571:31) at Function.gt (C:\Users\rodd_harris\AppData\Roaming\npm\node_modules\gulp\node_modules\semver\semver.js:600:10) at Liftoff.handleArguments (C:\Users\rodd_harris\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:99:14) at Liftoff. (C:\Users\rodd_harris\AppData\Roaming\npm\node_modules\gulp\node_modules\liftoff\index.js:192:16) at module.exports (C:\Users\rodd_harris\AppData\Roaming\npm\node_modules\gulp\node_modules\liftoff\node_modules\flagged-respawn\index.js:17:3) at Liftoff. (C:\Users\rodd_harris\AppData\Roaming\npm\node_modules\gulp\node_modules\liftoff\index.js:185:9) at C:\Users\rodd_harris\AppData\Roaming\npm\node_modules\gulp\node_modules\liftoff\index.js:159:9 at C:\Users\rodd_harris\AppData\Roaming\npm\node_modules\gulp\node_modules\v8flags\index.js:91:14
What am I doing wrong?
Edit
By some experimenting, I found that gulp will run if I do gulp -v
first. If I open a command prompt and go to my project directory and just run gulp
I get the same error as I do from Task Runner. However, if, as I said, I do the gulp -v
first, then run gulp
it works.
It would still be nice to know if I've got something configured wrong because at present, I'm still unable to set this up with Task Runner Explorer.
Upvotes: 2
Views: 5664
Reputation: 4243
I found a solution to this issue, make sure you have run npm init in the base directory of your gulp file and then install gulp locally npm install gulp --save-dev. This seems to resolve it for me when running gulp in Visual Studio Code.
Upvotes: 1