Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

christopher's avatar

Elixir gulp --production on Forge Server

Heyho -

i edited my deploy script and added gulp --production to the tasks.

On my forge server i installed gulp with sudo npm install --global gulp after this i did a sudo npm install .

If i now run my deploy script i get the error message

odule.js:338
    throw err;
          ^
Error: Cannot find module 'shellwords'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/home/forge/domain.com/node_modules/laravel-elixir/node_modules/gulp-notify/node_modules/node-notifier/lib/utils.js:5:18)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)

I searched the web, but didnt found anything about this specific error. What could be the problem?

And is this the right way to minify the files on the server?

0 likes
6 replies
Dunkelheit's avatar

Let's see your gulpfile.js first.

I would personally not do anything gulp related on the server. Instead I'd do on my local machine and then use git push to have my Forge automatically git pull stuff on the server.

christopher's avatar

This is my gulpfile. Locally its all working

var elixir = require('laravel-elixir');

/*
 |--------------------------------------------------------------------------
 | Elixir Asset Management
 |--------------------------------------------------------------------------
 |
 | Elixir provides a clean, fluent API for defining some basic Gulp tasks
 | for your Laravel application. By default, we are compiling the Sass
 | file for our application, as well as publishing vendor resources.
 |
 */

elixir(function(mix) {

    /*
    Copy Files from bower to the resources directory
     */
    mix.copy('vendor/bower_components/bootstrap/fonts', 'resources/assets/fonts');
    mix.copy('vendor/bower_components/chartist/dist/chartist.min.css', 'public/css/chartist.css');
    mix.copy('vendor/bower_components/bootstrap/less', 'resources/assets/less/bootstrap');
    mix.copy('resources/assets/fonts', 'public/fonts');

    /*
    Copy JS Files
     */
    mix.copy('vendor/bower_components/jquery/dist/jquery.js', 'resources/assets/js');
    mix.copy('vendor/bower_components/bootstrap/js', 'resources/assets/js');
    mix.copy('vendor/bower_components/chartist/dist/chartist.js', 'resources/assets/js/chartist.js');
    mix.copy('vendor/bower_components/chartist-plugin-axistitle/dist/chartist-plugin-axistitle.js', 'resources/assets/js/chartist-plugin-axistitle.js');
    mix.copy('vendor/bower_components/chartist-plugin-tooltip/dist/chartist-plugin-tooltip.js', 'resources/assets/js/chartist-plugin-tooltip.js');
    mix.copy('vendor/bower_components/chartist-plugin-pointlabels/dist/chartist-plugin-pointlabels.js', 'resources/assets/js/chartist-plugin-pointlabels.js');

    /*
    Compile less files
     */
    mix.less('app.less');

    /*
    Mix JS Files
     */
    mix.scripts([
        'jquery.js',
        'affix.js',
        'collapse.js',
        'dropdown.js',
        'modal.js',
        'tooltip.js',
        'transition.js',
        'button.js',
        'alert.js',
        'tab.js',
        'chartist.js',
        'chartist-plugin-axistitle.js',
        'chartist-plugin-tooltip.js',
        'chartist-plugin-pointlabels.js',
        'custom.js'
    ]);

    /*
    Version Files
     */
    mix.version(['css/app.css', 'fonts/*', 'js/all.js']);
});
sj's avatar

@kayyyy Are you using Phpstorm? when i use mix.version my phpstorm is getting slow because i have so many files it needs to generate every time

taijuten's avatar

Personally, I'd not use gulp server-side.

I've found that historically, gulp can be a little fragile. An update here can break the process. If you're running gulp server-side for production, there may be issues that appear which you'd normally spot on your development environment.

If for whatever reason, gulp fails, then your forge-hosted site is down.

If you'd rather not remember to do gulp --production before each push, then you could always use a combination of shell scripts / aliases to automatically gulp --production & git push

christopher's avatar

okay - then i will run gulp for production only if i really push the files for production :)

Thought it would be a better way to just push all files to the repo and then forge does the rest.

taijuten's avatar

In theory it's a good idea, but practically, you only want your server to deal with serving your website. You don't want it to deal with any stage of your development.

Please or to participate in this conversation.