Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal server error: No "exports" main defined #46

Closed
sedric-eyal-peleg opened this issue Jul 20, 2022 · 10 comments
Closed

Internal server error: No "exports" main defined #46

sedric-eyal-peleg opened this issue Jul 20, 2022 · 10 comments

Comments

@sedric-eyal-peleg
Copy link

sedric-eyal-peleg commented Jul 20, 2022

I'm receiving the following error upon tuning my Vite+React app:

12:57:46 PM [vite] Internal server error: No "exports" main defined in ~/app/node_modules/vite-plugin-svgr/node_modules/@svgr/core/package.json imported from ~/app/node_modules/vite-plugin-svgr/dist/index.mjs
  Plugin: vite-plugin-svgr
  File: ~/app/src/components/icons/affiliates-manage-icon.svg
      at new NodeError (node:internal/errors:372:5)
      at throwExportsNotFound (node:internal/modules/esm/resolve:472:9)
      at packageExportsResolve (node:internal/modules/esm/resolve:693:7)
      at packageResolve (node:internal/modules/esm/resolve:935:14)
      at moduleResolve (node:internal/modules/esm/resolve:1003:20)
      at defaultResolve (node:internal/modules/esm/resolve:1218:11)
      at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
      at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18)
      at ESMLoader.import (node:internal/modules/esm/loader:380:22)
      at importModuleDynamically (node:internal/modules/esm/translators:106:35)

This is my vite.config.ts

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import svgr from 'vite-plugin-svgr';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react(), svgr()],
  resolve: {
    alias: {
      src: path.resolve(__dirname, './src'),
    },
  },
});

We use the same usage logic according to https://www.npmjs.com/package/vite-plugin-svgr

These are the versions of the packages we use:

"react": "^18.2.0",
"vite": "^3.0.0"
"vite-plugin-svgr": "^2.2.0",
"@vitejs/plugin-react": "^2.0.0",
@zhanzizhen
Copy link

same to me

@MartinRybergLaude
Copy link

Same for me as well, something must've gone wrong with the recent re-releases.

@mianbato
Copy link

Same problem since yesterday

@linzeguang
Copy link

I solved the problem by adding ""resolutions": {"@svgr/core": "6.2.1"}" to the package.json file

@pd4d10
Copy link
Owner

pd4d10 commented Jul 20, 2022

Hi, thanks for all the feedback!

According to the context provided by @linzeguang, is it caused by the new version of @svgr/core (this package's dependency)?

@linzeguang
Copy link

Hi, thanks for all the feedback!

According to the context provided by @linzeguang, is it caused by the new version of @svgr/core (this package's dependency)?

I think it should be, but I didn't compare the difference between the old and new versions of @svgr/core

@MartinRybergLaude
Copy link

Hi, thanks for all the feedback!

According to the context provided by @linzeguang, is it caused by the new version of @svgr/core (this package's dependency)?

Probably related to this, at least that's my guess.

@zhanzizhen
Copy link

I solved the problem by adding ""resolutions": {"@svgr/core": "6.2.1"}" to the package.json file

use version 1.x also solve the problem

vite-plugin-svgr@^1.0.0:
  version "1.1.0"
  resolved "http://bnpm.byted.org/vite-plugin-svgr/-/vite-plugin-svgr-1.1.0.tgz#75b0e1eb55acadb8ab2666b736e9d1428887326f"
  integrity sha512-fuwfRpUoMBX3wr47JVt4b4xpMYujONDGyDwZFE4JuohVTJovJ4VCNeAb3//mzdRxdzeHEfJuedpoHTvwPsqisA==
  dependencies:
    "@svgr/core" "^6.2.0"

@wood3n
Copy link

wood3n commented Jul 22, 2022

it seems that this problem will be fixed by this pr: gregberge/svgr#749

@pd4d10 pd4d10 closed this as completed in e893c5e Jul 22, 2022
@pd4d10
Copy link
Owner

pd4d10 commented Jul 22, 2022

Released v2.2.1

Updated @svgr/core to v6.3.1, which seems to have fixed this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants