Issue with JavaScript action compilation

0
ERROR in ../../../../../../Users/j/Mendix/BaseDeDonnee-main/deployment/tmp/jsactions.js 1:0Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (1:0)File was processed with these loaders: * ./node_modules/babel-loader/lib/index.jsYou may need an additional loader to handle the result of these loaders.> export const MyFirstModule$JavaScript_action = async () => (await import("C:/Users/julio.roigt/Mendix/BaseDeDonnee-main/javascriptsource/myfirstmodule/actions/JavaScript_action")).JavaScript_action; webpack compiled with 1 error
asked
3 answers
0

Hello, I'm experiencing the same issue. Have you found what the issue is? :) 

answered
0

This error message indicates that your Mendix project's build process is trying to handle a JavaScript file that uses modern ES Module syntax (import/export), but the build tool (Webpack, via Babel) isn't configured to understand it.

The root cause is almost always related to the project's tooling configuration, often tied to the version of Mendix Studio Pro you are using.

 

Here are the most common solutions, starting with the most likely to work.

  1. Upgrade Mendix Studio Pro: The single most effective solution is often to update to a more recent version of Mendix Studio Pro. Mendix regularly updates its underlying build tools (like Webpack and Babel) to support modern JavaScript features. An older version may not have the necessary 'sourceType: module' configuration built-in.

  2. Clean the Deployment Directory: Old, cached, or incorrectly generated files can cause conflicts.

    • In Mendix Studio Pro, go to App > Clean Deployment Directory.

    • Alternatively, you can manually delete the deployment folder from your Mendix project directory.

    • Run your project again. This forces Mendix to regenerate all necessary files with the correct configuration.

  3. Synchronize App Directory: Ensure your project's dependencies are correctly installed

 

## Understanding the Error Message

 

To give you a bit more context on what's happening behind the scenes:

  • 'import' and 'export': These keywords are part of the modern ES Module standard in JavaScript, used to share code between different files.

  • sourceType: module: This is a setting for Babel (a JavaScript compiler Mendix uses). It tells Babel, "Hey, the file you are about to read uses the modern import/export syntax, so please parse it as a module." The error means this setting was not active when Babel tried to process the file.

  • babel-loader: This is the Webpack plugin that integrates Babel into the build process.

  • jsactions.js: This is a temporary file that Mendix generates during the build process to bundle all your custom JavaScript actions together. The error appears here because this is the file Webpack and Babel are processing, even though the original code is in your /javascriptsource/ folder.

answered
0

Hi Marcian-Petrut,

 

Unfortunately, this doesn't solve my issue. This is what I have tried so far: 

 

Steps already tried:

  • Upgraded Mendix Studio (Upgraded and tested the branch in a higher Mendix version)
  • Deleted the deployment map
  • Cleaned the deployment directory
  • Downloaded the project fresh
  • Downgraded Node.js version from 22 to 18, Babel downgraded as well, then upgraded again since it didn't fix the issue
  • Synchronized the app directory
  • Removed all Mendix versions and re-installed
  • Reinstalled Node.js
  • Restarted the PC (“turned it off and on again”)

Since my colleagues don't experience this issue, I know it's related to my local configuration. I just don't know how to fix it.

 

Best

answered