0
votes

I am getting this error when I run grunt browserify

ReferenceError: [BABEL] src/app.js: Using removed Babel 5 option: base.stage - Check out the corresponding stage-x presets http://babeljs.io/docs/plugins/#presets while parsing file: src/app.js

This is my gruntfile

module.exports = function(grunt) {


  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    browserify: {
        main: {
          options: {
            browserifyOptions: {
              debug: true
            },
            transform: [["babelify", { "stage": 1 }]]
          },
          src: 'src/app.js',
          dest: 'scripts/app.js'
        }
    },
    watch: {
      files: [ 'src/**/*.js' ],
      tasks: ['browserify'],
      options: {
          spawn: false,
        },
    },
    connect: {
      target:{
            options: {
                port: 9001
            }
        }
    },
    bower: {
        flat: { /* flat folder/file structure */
            dest: 'scripts',
            options: {
                debugging: true
            }
        }
    }

  });

  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('main-bower-files');

  grunt.registerTask('default', [ 'bower', 'connect', 'watch']);
  grunt.registerTask('build', [ 'clean', 'bower', 'copy', 'uglify' ]);

};

And this is my babelrc

  {
    "presets": ["stage-1","es2015"]
  }

How can I fix it?

1
please add link to the project/files or publish content here. I have lots of experience with this and am able to solve your problem.guy mograbi
Hey, thank you for taking a look! github.com/lukasoktaba/run-testuser3943543
The project works when you clone it.. what is the change you're trying to do that causes the issue?guy mograbi
According to this you might be importing the entire repository instead of a specific file.guy mograbi
It's when I save app.js in src. It won't copy to scripts.user3943543

1 Answers

2
votes

The error means that the grunt definition for babelify is obsolete and invalid.

It does not accept an option named stage anymore.

I would try

 browserify: {
        main: {
          options: {
            browserifyOptions: {
              debug: true
            },
            transform: [["babelify",  {presets: ["stage-1", "es2015"]}]]
          },
          src: 'src/app.js',
          dest: 'scripts/app.js'
        }
    },

replace {stage: 1} with {presets: ... }

Or - since you have this defined in .babelrc, you might be able to remove it altogether. I assume babelify applies those configurations.