最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to install gulp without npm on a shared hosting? - Stack Overflow

programmeradmin1浏览0评论

On my shared hosting I would like to have access to gulp (gulp watch) to pile my LESS assets into CSS. To install gulp I must have npm installed as well.

Unfortunately hosting administrator refused to install npm. Is there any other way to get gulp working on my server?

My gulpfile.js is presented below:

var gulp = require('gulp'),
    connect = require('gulp-connect'),
    less = require('gulp-less');

gulp.task('webserver', function() {
    connect.server({
        livereload: true
    });
});

gulp.task('less', function() {
    gulp.src('assets/less/app.less')
        .pipe(less())
        .on('error', console.log.bind(console))
        .pipe(gulp.dest('css'))
        .pipe(connect.reload());
});

gulp.task('fonts', function() {
    gulp.src([
        'bower_ponents/bootstrap/fonts/*',
        'bower_ponents/fontawesome/fonts/*'
    ])
    .pipe(gulp.dest('fonts'));
});

gulp.task('watch', function() {
    gulp.watch('assets/less/*.less', ['less']);
});

gulp.task('default', ['webserver', 'less', 'fonts', 'watch']);

Probably I would need to do the same with bower. Making long story short - I just developed my small tiny project on my OS X MAMP localhost where I did all the stuff in terminal (bower search etc. gulp watch etc.)

In terms of my hosting I also have access to the shell via ssh -l login host.

Thank you for any hints or even a clear answer that it's impossible.

On my shared hosting I would like to have access to gulp (gulp watch) to pile my LESS assets into CSS. To install gulp I must have npm installed as well.

Unfortunately hosting administrator refused to install npm. Is there any other way to get gulp working on my server?

My gulpfile.js is presented below:

var gulp = require('gulp'),
    connect = require('gulp-connect'),
    less = require('gulp-less');

gulp.task('webserver', function() {
    connect.server({
        livereload: true
    });
});

gulp.task('less', function() {
    gulp.src('assets/less/app.less')
        .pipe(less())
        .on('error', console.log.bind(console))
        .pipe(gulp.dest('css'))
        .pipe(connect.reload());
});

gulp.task('fonts', function() {
    gulp.src([
        'bower_ponents/bootstrap/fonts/*',
        'bower_ponents/fontawesome/fonts/*'
    ])
    .pipe(gulp.dest('fonts'));
});

gulp.task('watch', function() {
    gulp.watch('assets/less/*.less', ['less']);
});

gulp.task('default', ['webserver', 'less', 'fonts', 'watch']);

Probably I would need to do the same with bower. Making long story short - I just developed my small tiny project on my OS X MAMP localhost where I did all the stuff in terminal (bower search etc. gulp watch etc.)

In terms of my hosting I also have access to the shell via ssh -l login host.

Thank you for any hints or even a clear answer that it's impossible.

Share Improve this question asked Jul 12, 2015 at 13:41 Matt KomarnickiMatt Komarnicki 5,4428 gold badges48 silver badges97 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 6

You can not use gulp without node, but gulp is devel tool.

I think you not need gulp on production server. On production server usually you give files processed with gulp, but no gulp directly.

gulp.task('webserver', function() {
    connect.server({
        livereload: true
    });
});

This is a gulp task never needed on production.

gulp.task('less', function() {
    gulp.src('assets/less/app.less')
        .pipe(less())
        .on('error', console.log.bind(console))
        .pipe(gulp.dest('css'))
        .pipe(connect.reload());
});
// ...
gulp.task('watch', function() {
    gulp.watch('assets/less/*.less', ['less']);
});

These are gulp task never needed on production. You should be putting the piled CSS files onto the server, perhaps only the piled CSS and not the .less files.

gulp.task('fonts', function() {
    gulp.src([
        'bower_ponents/bootstrap/fonts/*',
        'bower_ponents/fontawesome/fonts/*'
    ])
    .pipe(gulp.dest('fonts'));
});

This is a gulp task never needed on production. You can simply put those files on the server in the piled destination.

In short, just put your piled files on prod. Gulp is a build tool. Push the build to production, not the source code.

You can still use NPM, even if your administrator won't install it (or node) for you:

  1. Download the standalone version of Node (node.exe)
  2. Clone the NPM project from Github (which is a standard node project) and place it in the same folder as the node.exe file
  3. Use npm as follows: node.exe npm install gulp or C:\Users\me\some-folder-you-can-write-to\node.exe npm install gulp
发布评论

评论列表(0)

  1. 暂无评论