Products | Versions |
---|---|
Spotfire Analyst | 14.4 and Higher |
When developing an action mod that uses JavaScript libraries, you may encounter the error "X [ERROR] Could Not Resolve '<module name>'" (e.g., "X [ERROR] Could Not Resolve 'moment'") during the build process (`npm run build`), even if the library has been installed (`npm install <package name>`) and imported correctly into your script. This issue often arises because additional configurations or plugins may be required for the bundler to recognize and include external dependencies properly.
To resolve this issue:
1. In `tsconfig.json, add:
"moduleResolution": "Bundler"
2. In `esbuild.config.js`, add:
mainFields: ["main"]
After making these changes, you can import the module as follows in your script:
import moment from "<ModuleName>"; For example: import moment from "moment";
Getting started
https://spotfiresoftware.github.io/spotfire-mods/docs/getting-started
Developing action mods
https://spotfiresoftware.github.io/spotfire-mods/docs/action-mods/developing-action-mods/