简体   繁体   English

如何在共享主机上安装没有npm的gulp?

[英]How to install gulp without npm on a shared hosting?

On my shared hosting I would like to have access to gulp ( gulp watch ) to compile my LESS assets into CSS. 在我的共享主机上,我想访问gulp( gulp watch )将我的LESS资产编译成CSS。 To install gulp I must have npm installed as well. 要安装gulp我也必须安装npm。

Unfortunately hosting administrator refused to install npm. 不幸的是托管管理员拒绝安装npm。 Is there any other way to get gulp working on my server ? 有没有其他方法让gulp在我的服务器上工作

My gulpfile.js is presented below: 我的gulpfile.js如下所示:

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_components/bootstrap/fonts/*',
        'bower_components/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. ) 长话短说 - 我刚刚在我的OS X MAMP本地主机上开发了我的小项目,在那里我做了终端的所有东西( bower search etc. gulp watch etc.

In terms of my hosting I also have access to the shell via ssh -l login host . 就我的托管而言,我也可以通过ssh -l login host 访问shell

Thank you for any hints or even a clear answer that it's impossible. 感谢您提供任何暗示甚至是明确的答案,这是不可能的。

You can not use gulp without node, but gulp is devel tool. 你不能在没有节点的情况下使用gulp,但gulp是devel工具。

I think you not need gulp on production server. 我认为你不需要在生产服务器上吞下去。 On production server usually you give files processed with gulp, but no gulp directly. 在生产服务器上,您通常会使用gulp处理文件,但不能直接使用gulp。

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

This is a gulp task never needed on production. 这是生产中从未需要的gulp任务。

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. 这些是生产中从不需要的gulp任务。 You should be putting the compiled CSS files onto the server, perhaps only the compiled CSS and not the .less files. 您应该将已编译的CSS文件放到服务器上,可能只是编译的CSS而不是.less文件。

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

This is a gulp task never needed on production. 这是生产中从未需要的gulp任务。 You can simply put those files on the server in the compiled destination. 您只需将这些文件放在已编译目标的服务器上即可。

In short, just put your compiled files on prod. 简而言之,只需将编译后的文件放在prod上即可。 Gulp is a build tool . Gulp是一个构建工具 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: 您仍然可以使用NPM,即使您的管理员不会为您安装它(或节点):

  1. Download the standalone version of Node (node.exe) 下载独立版本的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 从Github(这是一个标准节点项目)克隆NPM项目并将其放在与node.exe文件相同的文件夹中
  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 使用npm如下: node.exe npm install gulpC:\\Users\\me\\some-folder-you-can-write-to\\node.exe npm install gulp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM