Why does SFDMU command fail in the force-app directory with SF CLI?
Question:
The source code of the Plugin has been linked in some directory, for example, SFDX-Data-Move-Utility-master
.
I want to execute the sf sfdmu run
command inside the root folder of my force-app
project or one of its subfolders like force-app
, force-app/main
, etc.
However, I encounter an error displayed as a SyntaxError related to import statements outside a module. The error message is as follows:
(node:22516) SyntaxError Plugin: sfdmu: Cannot use import statement outside a module
module: @oclif/core@3.12.0
task: cacheCommand
plugin: sfdmu
root: C:\Repository\SFDX-Data-Move-Utility-master
See more details with DEBUG=*
(Use `node --trace-warnings ...` to show where the warning was created)
» Error: Command sfdmu:run not found.
What causes this issue and how can it be resolved?
Answer:
The issue likely stems from a conflict between the local environment setup and the SFDMU package configuration, particularly due to the linked source code in directories like SFDX-Data-Move-Utility-master
.
Executing commands within the force-app
folder, which is part of an independent Salesforce project treated similarly to a Node.js package, might introduce conflicts with the plugin's requirements.
Solution:
Installation Method: Instead of linking the Git source version of SFDMU using
sf plugins link
, install SFDMU as a Salesforce plugin with the commandsf plugins install sfdmu
. This method ensures that the plugin integrates more smoothly with the Salesforce CLI environment, reducing potential conflicts.Execution Directory: If you choose to continue using the linked version of the plugin, execute the SFDMU commands outside the
force-app
directory to avoid interference with the project's Node.js-like structure. Consider running these commands from a neutral location such as the parent directory whereSFDX-Data-Move-Utility-master
is linked.