【问题标题】:Gulp command opens gulp.js in notepad instead of running itGulp 命令在记事本中打开 gulp.js 而不是运行它
【发布时间】:2015-05-08 15:57:40
【问题描述】:

我认为我安装正确。

我的 package.json

   {
      "name": "my-project",
      "version": "0.1.0",
      "devDependencies": {
        "gulp": "^3.8.11",
        "gulp-concat": "^2.5.2"
      }
    }

我的 gulp.js

var gulp = require('gulp');

    var concat = require('gulp-concat');

    gulp.task('scripts', function() {
        return gulp.src('js/*.js')
          .pipe(concat('main.js'))
          .pipe(gulp.dest('build/js'));
    });

    gulp.task('default', ['scripts']);

我的文件夹如下:

ROOT/package.json
ROOT/gulp.js
ROOT/node-modules/   <-- my modules are here
ROOT/js/  <-- my js are here

当我在命令行中运行 gulp 时,位于 ROOT 文件夹中,gulp.js 只是在 Windows 记事本中打开,仅此而已..

为什么要这么做?

【问题讨论】:

  • 听起来 Windows 不知道执行它的 Nodejs 二进制文件。 node.bat gulp 是做什么的?
  • 它无法识别该命令
  • 节点已安装,node -v 提供 v0.12.2

标签: javascript windows node.js command-line gulp


【解决方案1】:

两个步骤: 第 1 步)将 gulp.js 重命名为 gulpfile.js,如上面的答案所示;步骤 2) 使用 npm install -g gulp-cli

【讨论】:

    【解决方案2】:

    一个简单的动作解决了问题:将 gulp.js 重命名为 gulpfile.js(叹气..)

    【讨论】:

    • 哈哈,我也是。显然是最好的:)
    猜你喜欢
    • 2018-04-11
    • 2013-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多