Issue with the gulp-babel plugin: Files within the Plugin/Preset should only export functions, not objects

I have started to integrate JavaScript 2015 (ES6) into my Ionic v1 app:

package.json

 {
  "name": "test",
  "version": "1.0.0",
  "dependencies": {
    "@ionic-native/deeplinks": "^4.18.0",
    "cordova-android": "7.0.0",
    "cordova-android-support-gradle-release": "1.2.1",
    "cordova-common": "1.5.1",
    "cordova-plugin-app-event": "1.2.1",
    "cordova-plugin-camera": "4.0.2",
    "cordova-plugin-datepicker": "git+https://github.com/VitaliiBlagodir/cordova-plugin-datepicker.git",
    "cordova-plugin-device": "2.0.1",
    "cordova-plugin-google-analytics": "1.7.11",
    "cordova-plugin-inappbrowser": "2.0.2",
    "cordova-plugin-network-information": "2.0.1",
    "cordova-plugin-splashscreen": "5.0.2",
    "cordova-plugin-whitelist": "1.3.3",
    "cordova-plugin-x-socialsharing": "5.3.2",
    "de.appplant.cordova.plugin.local-notification": "0.8.5",
    "es6-promise-plugin": "4.2.2",
    "ionic-native": "^2.9.0",
    "ionic-plugin-deeplinks": "^1.0.17",
    "ionic-plugin-keyboard": "2.2.1",
    "parse-push-plugin": "^1.0.7"
  },
  "devDependencies": {
    "@babel/core": "^7.2.2",
    "babel-loader": "^7.1.5",
    "babel-preset-es2015": "^6.24.1",
    "bower": "1.3.3",
    "gulp": "3.8.10",
    "gulp-babel": "^8.0.0",
    "gulp-concat": "2.2.0",
    "gulp-minify-css": "0.3.0",
    "gulp-plumber": "^1.2.1",
    "gulp-rename": "1.2.0",
    "gulp-sass": "2.2.0",
    "gulp-util": "2.2.14",
    "ionic-minify": "2.0.10",
    "shelljs": "0.3.0"
  },
  "cordovaPlugins": [
    "cordova-plugin-inappbrowser",
    "cordova-plugin-whitelist",
    "cordova-plugin-splashscreen",
    "cordova-plugin-camera",
    "cordova-plugin-x-socialsharing",
    "ionic-plugin-keyboard",
    "cordova-plugin-datepicker",
    "cordova-plugin-network-information",
    "de.appplant.cordova.plugin.local-notification",
    "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0e7e6f7c7d6b237e7b7d66237e627b6967604e3f203e2039">[email protected]</a>",
    "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e784889583889186ca978b92808e89ca808888808b82ca8689868b9e938e8494a7d6c9d0c9d6d6">[email protected]</a>",
    "cordova-custom-config",
    "ionic-plugin-deeplinks"
  ],
  "cordovaPlatforms": [
    "android"
  ],
  "cordova": {
    "plugins": {
      "cordova-plugin-datepicker": {},
      "cordova-plugin-network-information": {},
      "cordova-plugin-inappbrowser": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-camera": {},
      "cordova-plugin-x-socialsharing": {},
      "ionic-plugin-keyboard": {},
      "de.appplant.cordova.plugin.local-notification": {},
      "cordova-android-support-gradle-release": {
        "ANDROID_SUPPORT_VERSION": "26"
      },
      "parse-push-plugin": {},
      "cordova-plugin-google-analytics": {},
    },
    "platforms": []
  }
}

gulpfile.js:

var gulp = require('gulp');
var babel = require("gulp-babel");
var plumber = require("gulp-plumber");
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');

var paths = {
  es6: ['./src/es6/*.js'],
  sass: ['./scss/**/*.scss']
};

gulp.task('default', ['babel', 'sass']);

gulp.task("babel", function () {
  return gulp.src(paths.es6)
    .pipe(plumber())
    .pipe(babel({presets: ['es2015']}))
    .pipe(gulp.dest("www/js"));
});

gulp.task('sass', function(done) {
    gulp.src('./scss/ionic.app.scss')
      .pipe(sass())
      .pipe(gulp.dest('./www/css/'))
      .pipe(minifyCss({
        keepSpecialComments: 0
      }))
      .pipe(rename({ extname: '.min.css' }))
      .pipe(gulp.dest('./www/css/'))
      .on('end', done);
  });


gulp.task('watch', function() {
  gulp.watch(paths.es6, ['babel']);
  gulp.watch(paths.sass, ['sass']);
});

While attempting to run "gulp babel," I encountered the following error:

Error in plugin "gulp-babel"
Message:
    Plugin/Preset files are not allowed to export objects, only functions.

I suspect that this issue is related to incorrect version settings in devDependencies.

Despite trying different versions, I am still encountering errors.

If anyone can offer assistance in resolving this problem, it would be greatly appreciated.

Answer №1

My solution was to switch to using "gulp-babel": "^7.0.0"

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Certain conditions in JavaScript are not executed by Internet Explorer

I am currently working on a Html file that involves XSLT. I have integrated some JavaScript code for filtering specific rows within tables. However, I have encountered an issue where certain if-cases in my JavaScript are not executing as expected when usin ...

Is there a way to update a single document in a MongoDB database using Mongoose without directly referencing the document?

Let's say I have an example: 1 //Let's say I have an example 2 3 app.post('/update', validate, async (req, res) => { 4 const {title, description, post_id} = req.body; 5 6 // Updating one of them if they exist 7 ...

Can you explain the process of obtaining getServerSideProps results for my IndexPage?

Having trouble with the getServerSideProps function. I'm a beginner and struggling to figure out why it's not running properly. Spent hours trying to fix it, but still getting undefined in the IndexPage console.log(props.data) export default fun ...

The error message indicates that the Python executable "C:UsersAdminAnaconda3python.EXE" cannot be found, but you have the option to configure the PYTHON environment variable as a workaround

After downloading a project from github, I attempted to run npm install in my application. Unfortunately, I encountered the following error: > [email protected] install C:\Users\Admin\Desktop\New folder\flow\node_modu ...

Order of AngularJS Scope.on and Scope.emit Invocation in a Filter

One of the challenges I am facing involves watching a value in one controller that is changed in another controller within my filters. The goal is to determine whether an emit should be triggered based on the updated value. Here's the current situatio ...

Trigger refetchQueries post-execution of a mutation operation

In the past, I executed a mutation in a similar manner as shown below: export const useEditLocationName = () => { const [editFavoriteLocationName] = useEditFavoriteLocationNameMutation({ refetchQueries: [{ query: GetMyFavouritePlacesDocument}], ...

Issue with react-native-svg ForeignObject missing in project (React Native with Expo using TypeScript)

I am working on a React Native project in Expo and have incorporated the expo TypeScript configuration. Using "expo install," I added react-native-svg version 9.13.3 to my project. However, every time I attempt to render the SVG using react-native-svg, I ...

"JavaScript/jQuery: The pattern in the text does not align with the string

I am currently working on validating a text field with the specific data pattern of "I-MH-ABCD-ABC-1222". Below is the regular expression I have implemented, but unfortunately it is not functioning as intended. var router_added_sap = "I-MH-ABCD-ABC-1222" ...

Setting up NPM on a Linux operating system

I have a goal to set up AngularJS on my system! However, in order to do so, I require npm. To install Node.js for npm, I am encountering an error: File "./configure", line 16, in <module> from gyp.common import GetFlavor File "./tools/gyp/pylib/gyp/ ...

Retrieve an item fetched from the database using Javascript in MVC4 framework

How can I access the properties of an object returned from a database using JavaScript? This JavaScript function is invoked: function searchUser() { var userName = document.getElementById('UserName').value $.post("SearchForUser", { user ...

The absence of responseJSON in the jquery ajax response is causing an issue

Currently, I am developing a small web framework for conducting an HCI study and have encountered the following issue: In my setup, I have a Node server running with Express to serve local host data from JSON files. While it may not be the most advanced d ...

Purge excess bins that are not in use

I need to delete a large number of inactive bins from the system, but I can't find an option for mass deletion or inline editing using saved searches. Is there another method to accomplish this task since I have hundreds of records to delete? ...

Exclusive Modal Pop-Up for First-Time Visitors - Utilizing Bootstrap, PHP, and JavaScript

Seeking assistance from the community as I have exhausted my online research efforts. I am currently working on implementing a welcome bootstrap modal in a php environment. Despite being new to php and js, I have managed to make it pop up only once using ...

The functionality of the Regions plugin in wavesurfer.js appears to be completely nonfunctional

I've been attempting to utilize the Regions plugin from wavesurfer.js, but unfortunately, it's not functioning as expected. Despite trying various methods suggested on different websites, I have yet to achieve success. Below is the snippet of c ...

What could be causing my component to fail to load properly with Vite?

I have been working on a React project using Vite. Following a tutorial I discovered in an article at https://www.digitalocean.com/community/tutorials/how-to-set-up-a-react-project-with-vite, I encountered an issue. Despite following the tutorial step by ...

Obtaining the following class name from elements

I am struggling with extracting classes from a block of HTML code: <div class="container"> <div class="item first">...</div> <div class="item second">...</div> <div class="item third">...</div> <div cla ...

Implementing a PHP button update functionality sans utilizing an HTML form

I need a way to update my database with just a click of a button, without using any forms or POST requests. Most examples I've seen involve updating through forms and the $_POST method. Is there a simpler way to update the database by directly click ...

Enhancing the Efficiency of Android Programming

For my application, I am currently displaying 12 markers on a map, each of which triggers a dialog box showing the location's address when tapped. However, I believe there is a more efficient way to handle this. I have been experimenting with creating ...

A quicker method for setting the emitted value to data

Is there a way to pass data from child to parent without creating a method for assigning the value? I want to be able to assign it directly in the template. This is my current code: Child <h1 @click="$emit('title', 'Home')&quo ...

I am experiencing an issue where my application, built using NodeJS, Express, and Javascript, is failing to insert form data into the database despite

I am facing a challenge with my app's MVC design pattern where I am unable to insert form information into the corresponding table in the database. Despite installing the body-parser package via npm, the form is not functioning as expected. Can anyone ...