Importing npm packages in CRM custom extensions React.js

I attempted to import npm packages while creating a custom React app extension, specifically chalk and d3-react-tree, for testing purposes. I added these packages to package.json using the notation “chalk”: “latest”, as outlined in the README, while working with the CRM private app template.

However, I encountered some issues: In Example.jsx, chalk only functions properly in the local environment (hs project dev) and fails when deployed (hs project upload). Additionally, in example-function.js, any attempt to import results in a script crash, regardless of whether I use import chalk from ‘chalk’; or const chalk = require(‘chalk’);.

Has anyone successfully imported regular npm packages besides the preloads when creating React crm extensions?

Hi, @hubertspot :waving_hand: Thanks for your question. I’d like to invite some of our community members to the converstaion — hey @albertsg @zach_threadint @Teun have you run into this or similar issues in your project work?

Thank you for taking a look! — Jaycee