3

So I have followed: https://preset.io/blog/2020-07-02-hello-world/ for creating a simple hello-world plugin and also followed this video: https://www.youtube.com/watch?v=f6up5x_iRbI&t=936s

It worked really smooth in there but when I try it at my end, I run into a lot of issues. I tried running it on docker as well, still it didn't work. Pypi version seems to be outdated. Here's the error i get when I try to run npm run prod:

ERROR in ./src/visualizations/presets/MainPreset.js Module not found: Error: Can't resolve '@superset-ui/plugin-chart-hello-world' in '/home/spidey/apache_superset/superset-dev/incubator-superset/superset-frontend/src/visualizations/presets'

When I open the MainPreset.js file:

Here is how it looks: enter image description here And the bottom configuration: enter image description here

Going back to superset-frontend/node-modules/@superset-ui/ I have: enter image description here

When I run npm run dev-server: enter image description here But since I am running it on Virtual Instance so I can't open up the browser and check, whereas when I try npm run prod the error still persists: enter image description here

TylerH
  • 20,799
  • 66
  • 75
  • 101
Shivam Sahil
  • 4,055
  • 3
  • 31
  • 62

2 Answers2

1

I have a suspicion of what's happening here. Is it possible that your plugin is not in superset-frontend/package.json?

Note that if you put your hello-world plugin in package.json, and THEN do npm install, the npm install won't work. It's frustrating, but you need to do these things in the correct order:

  1. npm install (this nukes any npm links)
  2. add the plugin to your package.json (version number doesn't really matter)
  3. do the npm link ../../...... routine
  4. npm run dev-server

Hope that helps, but I'll continue to try to help wherever I'm able.

Evan Rusackas
  • 579
  • 4
  • 6
  • npm run dev-server ends with the message: `ℹ 「wdm」: 5951 modules ℹ 「wdm」: Compiled successfully.` The error comes when I try to run npm run prod. Is there any specific build process involved? – Shivam Sahil Jul 30 '20 at 07:34
  • Ahh, yes... prod would be a different, I think. NPM Links would not be included in the bundle, I don't think. The plugin would have to be published as part of `superset-ui` for that to work, which would then include it in the actual node-modules copy of superset-ui. Your copying it into that folder effectively short circuits that, placing the files there. – Evan Rusackas Aug 12 '20 at 22:40
1

Somehow npm link doesn't seem to work. Resolved by copying the chart-plugin-hello-world file directly to the superset-frontend/node-modules/@superset-ui/ directory. This is some issue with npm link hope it resolves in future.

Shivam Sahil
  • 4,055
  • 3
  • 31
  • 62