0

I've checked multiple related questions but none seems to fit.

I'm using multiple libraries in my web app, importing them inside Vue single file components without too much hassle as follows:

<script>
  import { DateTime } from 'luxon'
  import Sortable from 'sortablejs'

  export default {
    // etc...
  }
</script>

And I can use DateTime or Sortable or any other library in the code without issues.

I'm now trying to integrate Apache ECharts and it's giving me troubles.

Not so much due to the library itself, but in this case, for some reason when I import * as echarts from 'echarts' as stated in the official tutorial it returns the following error:

Module not found: Error: Can't resolve 'echarts' in '/whatever/folder/the/current/file/is'

"Whatever folder" means /main/src/components when importing from the base component, or /main/src when trying to import and register globally in the main.js file (as indicated in the first method here).

I know I could try the additional vue-echarts module but I really would like to understand why in this case the loader is looking into the current folder and not in node_modules as in the other cases.


NOTES

  • echarts is present in the node_modules folder together with the other libraries I use without issues
  • I've tried also import echarts from 'echarts'

** EDIT **

  • Also tried to import submodules, such as import * from 'echarts/core'
  • Also tried to use const echarts = require('echarts')
  • Having the same issue with Chart.js, but still not with other libraries I was already using... 😳

Any help will be appreciated.

5
  • have you tried importing from 'echarts/core' or 'echarts/charts' instead of just 'echarts'? The module not found error is indicating in which file the missing module is imported and not where it is imported from, hence the directory it is showing. It will still look in node_modules I believe Commented Aug 20, 2021 at 14:03
  • import * as echarts from 'echarts/core'; Commented Aug 20, 2021 at 14:05
  • exactly the same thing as above: it gives me Module not found: Error: Can't resolve 'echarts/core' in '/main/src' Commented Aug 20, 2021 at 14:08
  • Might be an issue with how echarts was installed or something but webpack seems to be working correctly...hard to tell without reproducing Commented Aug 20, 2021 at 14:26
  • I've tried uninstalling and reinstalling multiple times, and made sure the package.json and package-lock.json included the libraries. What could create issues with newly installed libraries but not with old ones? Commented Aug 20, 2021 at 17:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.