警告:找不到任务 "browserfy"

Warning: Task "browserfy" not found

我想用browserfy把es6文件转成es5。但是每次执行监视任务时,我都会收到错误消息:

Warning: Task "browserfy" not found. Use --force to continue.

我使用以下 gruntfile(简化)自动执行任务:

grunt.initConfig({
browserfy: {
  dist: {
    options: {
      transform: [
        ["babelify", {
          loose: "all"
        }]
      ]
    },
    files: {
      "dist/module.js": ["lib/main.js"]
    }
  }
},
watch: {
  lib_test: {
    files: '<%= jshint.lib_test.src %>',
    tasks: ['jshint:lib_test', 'browserfy'/*, 'qunit'*/]
  }
}});

grunt.loadNpmTasks("grunt-browserify");
grunt.loadNpmTasks('grunt-contrib-watch');

我也用过命令

npm install grunt-browserify --save-dev

问题解决了。我打错了。它是“浏览器ify.