0

Working on a project and I've decided to use gulp for Typescript watching and transpiling.

Here are the steps I took to install everything.

All this is done within the root directory of my project:

$ sudo npm update
$ npm -v #1.3.10
$ npm init #to create the package.json
$ sudo npm install gulp -g #installing gulp globally
$ gulp -v # No version number is shown.. why?
$ npm install gulp --save-dev
$ npm install gulp-typescript
$ vim gulpfile.js

Here are the contents of my gulpfile.js:

var gulp = require('gulp');
var ts = require('gulp-typescript');

var tsProject = ts.createProject({
    declaration: true,
    noExternalResolve: true
});

gulp.task('scripts', function() {
    return gulp.src('web/ts/*.ts')
                    .pipe(ts(tsProject))
                    .pipe(gulp.dest('web/js'))
});
gulp.task('watch', ['scripts'], function() {
    gulp.watch('web/ts/*.ts', ['scripts']);
});

However, I get nothing when I run $ gulp scripts. No error. What am I doing wrong?

gulp-typescript

kemicofa ghost
  • 16,349
  • 8
  • 82
  • 131
  • why did you install gulp with `sudo`? this means you'll have to run `gulp` as root everytime? – br3w5 Oct 09 '15 at 13:53
  • @br3w5 Well I need the rights to install gulp globally, no? I get a beautiful error when I try to install gulp globally without sudo. – kemicofa ghost Oct 09 '15 at 14:01
  • yes but it looks like you also installed node with sudo is that right? so you won't be able to run npm unless you are root – br3w5 Oct 09 '15 at 14:08
  • also check this http://stackoverflow.com/questions/17990647/npm-install-errors-with-error-enoent-chmod – br3w5 Oct 09 '15 at 14:10
  • Your `npm` is quite old (see releases here https://github.com/npm/npm/releases) You can update your npm this way: http://stackoverflow.com/questions/6237295/how-can-i-update-node-js-and-npm-to-the-next-versions – MartyIX Oct 11 '15 at 11:47

1 Answers1

1

After MartylX comment, I began checking my npm and node versions and they were clearly not uptodate.. which I thought was awkward seeing that I had installed them recently.

I decided to completely reinstall everything.

$ sudo apt-get remove node
$ sudo apt-get remove nodejs
$ sudo apt-get remove npm

I decided to install NVM:

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash

And I installed the latest version of node:

$ nvm install stable
$ node -v #v4.1.2

I then reinstalled npm:

$ sudo apt-get install npm

I then updated it:

$ sudo npm update -g npm
$ npm -v #2.14.4

And then I installed gulp globally (as well as at the root of my project):

$ sudo npm install -g gulp
$ npm install gulp --save-dev #make sure you did an npm init if you haven't yet
$ gulp #errors are now shown!
kemicofa ghost
  • 16,349
  • 8
  • 82
  • 131