<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Using amCharts in a React Module (Missing version constraints)</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=120831655" />
  <subtitle>Using amCharts in a React Module (Missing version constraints)</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=120831655</id>
  <updated>2026-04-04T00:37:36Z</updated>
  <dc:date>2026-04-04T00:37:36Z</dc:date>
  <entry>
    <title>Using amCharts in a React Module (Missing version constraints)</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120831654" />
    <author>
      <name>André Bräkling</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120831654</id>
    <updated>2021-06-18T06:51:17Z</updated>
    <published>2021-06-17T13:07:05Z</published>
    <summary type="html">&lt;p&gt;Hello everybody,&lt;/p&gt;
&lt;p&gt;I created a simple React Portlet Module which should show a simple
  chart generated via amCharts, and in general, I followed &lt;a
    href="https://help.liferay.com/hc/en-us/articles/360017888032-Using-React-in-Your-Portlets"&gt;this
  tutorial&lt;/a&gt; and &lt;a
    href="https://github.com/liferay/liferay-blade-samples/tree/7.0/gradle/apps/npm/react-npm-portlet"&gt;this
  example&lt;/a&gt;. Currently, I'm using Liferay DXP 7.1.10 GA 1
  (dxp-23-7110) on my local development machine.&lt;/p&gt;
&lt;p&gt;As a simple &amp;quot;Hello world&amp;quot; portlet, everything works as
  expected. I can also add amCharts as a devDependency to my package.json:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-java"&gt;{
	&amp;quot;dependencies&amp;quot;: {
		&amp;quot;react&amp;quot;: &amp;quot;16.8.6&amp;quot;,
		&amp;quot;react-dom&amp;quot;: &amp;quot;16.8.6&amp;quot;
	},
	&amp;quot;devDependencies&amp;quot;: {
		&amp;quot;babel-cli&amp;quot;: &amp;quot;^6.26.0&amp;quot;,
		&amp;quot;babel-preset-env&amp;quot;: &amp;quot;^1.7.0&amp;quot;,
		&amp;quot;babel-preset-react&amp;quot;: &amp;quot;6.24.1&amp;quot;,
		&amp;quot;liferay-npm-bundler&amp;quot;: &amp;quot;2.19.4&amp;quot;,
		&amp;quot;liferay-npm-bundler-loader-json-loader&amp;quot;: &amp;quot;^2.20.0&amp;quot;,
		&amp;quot;@amcharts/amcharts4&amp;quot;: &amp;quot;^4.10.19&amp;quot;
	},
	&amp;quot;main&amp;quot;: &amp;quot;lib/index.es.js&amp;quot;,
	&amp;quot;name&amp;quot;: &amp;quot;net-kex-visualization-tagcloud-web&amp;quot;,
	&amp;quot;scripts&amp;quot;: {
		&amp;quot;build&amp;quot;: &amp;quot;babel --source-maps -d build/resources/main/META-INF/resources src/main/resources/META-INF/resources &amp;amp;&amp;amp; liferay-npm-bundler&amp;quot;
	},
	&amp;quot;version&amp;quot;: &amp;quot;1.0.0&amp;quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Building and deploying works as expected, amCharts appears inside my
  node_modules folder. And my &amp;quot;Hello World&amp;quot; application still
  works without any issues.&lt;/p&gt;
&lt;p&gt;Now, I import amCharts into my TagCloud.es.js component (in this
  example I'd like to create a simple tag cloud):&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-java"&gt;import React, { Component } from 'react';

import * as am4core from &amp;quot;@amcharts/amcharts4/core&amp;quot;;
import * as am4charts from &amp;quot;@amcharts/amcharts4/charts&amp;quot;;


class TagCloud extends Component {
  render() {
      return (
        &amp;lt;h1&amp;gt;Hello world&amp;lt;/h1&amp;gt;
      );
    }
}

export { TagCloud };&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I don't change anything else, just import amCharts to start using it
  afterwards. But now my portlet stops working and I receive this error
  message within my browser console:&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;development:4485 Error: The following problems where detected while
    resolving modules:&lt;br /&gt;Missing version constraints for
    @net-kex-visualization-tagcloud-web$amcharts/amcharts4 in
    package.json of
    net-kex-visualization-tagcloud-web@1.0.0/core&lt;br /&gt;Missing version
    constraints for
    @net-kex-visualization-tagcloud-web$amcharts/amcharts4 in
    package.json of net-kex-visualization-tagcloud-web@1.0.0/charts&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The &amp;quot;resolved modules&amp;quot; list of the AMD Loader shows these entries:&lt;/p&gt;
&lt;blockquote&gt;
  &lt;ol&gt;
    &lt;li&gt;74: &amp;quot;:ERROR:Missing version constraints for
      @net-kex-visualization-tagcloud-web$amcharts/amcharts4 in
      package.json of net-kex-visualization-tagcloud-web@1.0.0/core&amp;quot;&lt;/li&gt;
    &lt;li&gt;75: &amp;quot;:ERROR:Missing version constraints for
      @net-kex-visualization-tagcloud-web$amcharts/amcharts4 in
      package.json of net-kex-visualization-tagcloud-web@1.0.0/charts&amp;quot;&lt;/li&gt;&lt;/ol&gt;&lt;/blockquote&gt;
&lt;p&gt;Of course, I tried to google this error message, and I found some
  Liferay related discussions, but nothing helpful except the notice,
  that &lt;a
    href="https://github.com/liferay/liferay-amd-loader/issues/166"&gt;there
    was a bug some time ago in the AMD loader&lt;/a&gt;, which is already
  fixed. This is why I switched my Liferay docker image I'm using
  locally from -sp4 to -sp6, but with no change.&lt;/p&gt;
&lt;p&gt;Next, I used CodeSandbox to try creating a little amCharts app with
  React outside of Liferay: &lt;a
  href="https://codesandbox.io/s/mutable-dream-w637m"&gt;https://codesandbox.io/s/mutable-dream-w637m&lt;/a&gt; (no
  TagCloud, I just copied an amCharts React example).&lt;/p&gt;
&lt;p&gt;This works like a charm, no errors, quick building, etc. - but with
  one difference: Here, amCharts is added to dependencies instead of
  devDependencies. Makes sense to me, because amCharts should be
  available in the user's client browser. So, I just tried to move it to
  dependencies, but then my module does not start anymore.&lt;/p&gt;
&lt;p&gt;But, because of this, I also had a closer look at the node_modules,
  which contains more than 20.000 files... That seems very strange to
  me. And so I wonder if we might be mixing server-side and client-side
  modules here... because basically I just want to load and use a simple
  library in my user's browser, and don't get why this causes such issues.&lt;/p&gt;
&lt;p&gt;Any support would be greatly appreciated. Somehow I can't get rid of
  the feeling that I'm overlooking something very basic...!&lt;/p&gt;</summary>
    <dc:creator>André Bräkling</dc:creator>
    <dc:date>2021-06-17T13:07:05Z</dc:date>
  </entry>
</feed>
