【发布时间】:2016-01-07 11:49:07
【问题描述】:
从事一个项目,我决定使用 gulp 进行 Typescript 观察和转译。
这是我安装所有东西的步骤。
这一切都是在我项目的根目录中完成的:
$ 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
这是我的 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']);
});
但是,当我运行 $ gulp scripts 时,我什么也没得到。没有错误。我做错了什么?
【问题讨论】:
-
你为什么用
sudo安装gulp?这意味着您每次都必须以 root 身份运行gulp? -
@br3w5 我需要全局安装 gulp 的权限,不是吗?当我尝试在不使用 sudo 的情况下全局安装 gulp 时,我收到了一个漂亮的错误。
-
是的,但看起来您还使用 sudo 安装了节点,对吗?所以除非你是 root 否则你将无法运行 npm
-
您的
npm已经很旧了(请参阅此处的版本 github.com/npm/npm/releases)您可以通过这种方式更新您的 npm:stackoverflow.com/questions/6237295/…
标签: ubuntu npm typescript gulp