podman-desktop / extension-minikube

Apache License 2.0
3 stars 10 forks source link

Minikube extension shows a failed status after installation #234

Closed amisskii closed 2 days ago

amisskii commented 3 days ago

After installing the Minikube extension using ghcr.io/podman-desktop/podman-desktop-extension-minikube:nightly, the Minikube extension shows a failed status. Error message from the extension details:

Error: require() of ES Module /home/amisskii/.local/share/containers/podman-desktop/plugins/ghcriopodmandesktoppodmandesktopextensionminikube/dist/extension.js from /app/lib/io.podman_desktop.PodmanDesktop/resources/app.asar/packages/main/dist/index.cjs not supported. extension.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead either rename extension.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /home/amisskii/.local/share/containers/podman-desktop/plugins/ghcriopodmandesktoppodmandesktopextensionminikube/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
Stack trace:
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/amisskii/.local/share/containers/podman-desktop/plugins/ghcriopodmandesktoppodmandesktopextensionminikube/dist/extension.js from /app/lib/io.podman_desktop.PodmanDesktop/resources/app.asar/packages/main/dist/index.cjs not supported.
extension.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename extension.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /home/amisskii/.local/share/containers/podman-desktop/plugins/ghcriopodmandesktoppodmandesktopextensionminikube/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

    at c._load (node:electron/js2c/node_init:2:16955)
    at _module._load (/app/lib/io.podman_desktop.PodmanDesktop/resources/app.asar/packages/main/dist/index.cjs:151:38636)
    at Xde.doRequire (/app/lib/io.podman_desktop.PodmanDesktop/resources/app.asar/packages/main/dist/index.cjs:151:65620)
    at Xde.loadRuntime (/app/lib/io.podman_desktop.PodmanDesktop/resources/app.asar/packages/main/dist/index.cjs:151:66331)
    at Xde.loadExtension (/app/lib/io.podman_desktop.PodmanDesktop/resources/app.asar/packages/main/dist/index.cjs:151:55697)

Minikube extension version: v0.5.0-next

Image Image

axel7083 commented 2 days ago

The problems seems to be related to the following line added

https://github.com/podman-desktop/extension-minikube/blob/4e15bade85f7d03422b84e54ecaa01948e77ac50/package.json#L9

we need to use .cjs format when using the type module.