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

Error message: Unexpected character found at the beginning of JSON data - REST API using node.js and Express

Recently, I have embarked on the journey of learning REST API with node and express. My main goal is to achieve file read and write operations using APIs. However, a frustrating error arises when attempting to hit the API through Postman. Strangely enough, ...

Express 4 Alert: Headers cannot be modified once they have been sent

I recently upgraded to version 4 of Express while setting up a basic chat system. However, I encountered an error message that says: info - socket.io started Express server listening on port 3000 GET / 304 790.443 ms - - Error: Can't set headers ...

Display or conceal fields depending on custom object specifications

I am attempting to centralize my show/hide functionality for fields in one object (like vm.foo) that contains key-value pairs. For example, I could add another pair like 1502: true to hide a field with the key 1502. Is there a way to pass variables from t ...

Using the useState hook with an array of objects is not functioning as intended

I have initialized a useState object in my file like this: const [comments, setComments] = useState({ step_up: [], toe_walking: [], toe_touches: [], squat: [], side_to_side: [], rolling: [], leg_lifts: [], hand_to_knees: [], floo ...

Unable to attach the script to recently added DOM elements

After spending considerable time working on this, I'm still unable to figure it out. You can find the page I am referring to at: The "show more" button at the bottom triggers additional posts to be displayed on the page using the following script: ...

What is the process of using an if statement in jQuery to verify the existence of a property in a JSON file?

I am working on a task to incorporate an if statement that checks for the existence of a specific property in a JSON file. If the property exists, I need to display its value within HTML tags <div class='titleHolder'> and "<div class=&ap ...

Learn how to incorporate a click event with the <nuxt-img> component in Vue

I am encountering an issue in my vue-app where I need to make a <nuxt-img /> clickable. I attempted to achieve this by using the following code: <nuxt-img :src="image.src" @click="isClickable ? doSomeStuff : null" /> Howeve ...

What causes the 'SyntaxError: Unexpected token import' when importing the d3-scale statement?

I recently wrote a simple code in ES6 import { scale } from 'd3-scale'; const a = scale.scalePow().domain([0, 20]).range([0, 1, 2, 30, 560, 1]); console.log(a(1)); To install the required dependency 'd3-scale', you can use: npm ins ...

Guide to making a JavaScript button that triggers an iframe to open upon user clicking the button

I'm currently enhancing the comment section for posts on my website. I am looking to implement a button in javascript that, when clicked, will open an iframe window displaying comments similar to how Facebook does on their post. If there are other lan ...

Using JSON data to render images onto a canvas

I am encountering an issue with a JSON array that I'm receiving from PHP. The array is indexed and has the following format (larger in real scenario) [ [ [17, 28, 1, "z"], [28, 31, 6, "b"], [8, 29, 6, "b"] ...

Encountered a RangeError with NPM due to an invalid triggerAsyncId while trying to install Node.js 12.6.0 on Windows 10

Encountering a challenge after installing Nodejs v12.6.0 on Windows 10 Pro. Node version retrieval works fine, but attempting to check the NPM version returns an error. As a result, I am unable to run my Node application on this machine due to this issue. ...

The issue of declaration merging and complications with nested node_modules

Here is the structure I am working with: @my/app node_modules @types/angular @types/angular-translate @my/library node_modules @types/angular The issue arises from the fact that @types/angular-translate extends the definitions of @types/angular ...

Choosing a button value from a form in Selenium: Best practices

I am looking to streamline the process of registering for classes. The snippet of HTML code on the page appears as follows: <form id="SearchClasses" name="selectedStatusForm" action="/more/SearchClasses.action" method=&quo ...

Next.js Content Switching: A Step-by-Step Guide

On my app, I have a main dashboard featuring a sidebar navigation and content container. However, being new to next.js and its routing system, I'm unsure how to update the content when a user navigates using the sidebar. Do I need to create separate p ...

There seems to be an issue with the NPM command configuration

I made changes to npm config set <key> <value> and now I'm experiencing issues when trying to run commands related to npm config. The error message I am receiving is: Error: Failed parsing JSON config key Is there a way to reset my npm ...

Angularjs - How come I am able to modify an object but not the list (ng-repeat) from a separate view?

After updating the customers object in the console, I noticed that the list (ng-repeat) is not reflecting the changes. What should I do? Interestingly, it works fine when I implement this function and view2.htm's HTML inside page.htm. HTML "page.htm" ...

When I attempted to POST a js::array in JSON, the response returned "undefined:undefined"

I have a javascript array on the frontend that I need to send to my Tomcat server. Currently, I am using the following code but encountering issues: console.log("preview list. postUsers()"); console.log(Ext.getCmp("preview-container").get ...

Mastering the Art of Integrating API and JSON!

I've developed a bot using botkit and the Zendesk API to retrieve information. There's a function in my bot that prompts the user for a search term, searches for relevant information using the Zendesk API, and displays the result. I'm faci ...

What is the most efficient way to transmit JSON data from a browser to a REST endpoint via Node.js, specifically in gzip format?

Currently working with node.js and express, I have a home page that hits my REST endpoint (PUT) after loading to send some JSON data. The data is not gziped when sending to the endpoint, but I want it to be in gzip form once it reaches the endpoint. Is thi ...

The error message I'm receiving is saying that the map function is not recognized for the posts variable (posts.map

I encountered a puzzling error, even though everything seems fine: posts.map is not a function import React from 'react' import { useSelector } from 'react-redux' export const PostsList = () => { const posts = useSelector(state = ...