Using gulp without global gulp //edit: and without linking to the bin js file

前端 未结 6 1228
野趣味
野趣味 2021-02-12 18:16

I have a gulpfile.js that runs through perfectly when typing gulp into the commandline.

All the gulp bash command really does is calling the sp

6条回答
  •  耶瑟儿~
    2021-02-12 18:20

    In package.json

    "scripts": {
       "gulp": "gulp"  
    },
    

    And then this command npm run gulp Also npm provides the ability to pass extra parameters to your commands. This is only the case for npm >= 2.0

    Update: Without bin link

    You can check the node_modules/.bin/gulp or node_modules/gulp/bin/gulp.js file to see how you can start gulp (Line 129 is interesting)

    I think this should work:

    var gulp = require('gulp');
    
    gulp.task('default', function() {
        console.log('do something');
    });
    
    gulp.start.apply(gulp, ['default']);
    

提交回复
热议问题