在做一个项目的时候,我决定用gulp来看打字稿和转写。
这里是我安装所有东西的步骤。
所有这些都是在我的项目的根目录中完成的:
$ 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时,我什么也得不到。没有错误。我做错了什么?
发布于 2015-10-12 08:02:51
在MartylX评论之后,我开始检查我的npm和节点版本,它们显然不是最新的。考虑到我最近安装了它们,我觉得很尴尬。
我决定完全重新安装所有的东西。
$ sudo apt-get remove node
$ sudo apt-get remove nodejs
$ sudo apt-get remove npm我决定安装NVM
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash我安装了节点的最新版本:
$ nvm install stable
$ node -v #v4.1.2然后我重新安装了国家预防机制:
$ sudo apt-get install npm然后,我更新了它:
$ sudo npm update -g npm
$ npm -v #2.14.4然后,我在全球范围内安装了gulp (以及我的项目的根):
$ 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!https://stackoverflow.com/questions/33039792
复制相似问题