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

Resolve error: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in ../node_modules/@splinetool/react-spline/package.json #215

Open
PoltP opened this issue Oct 30, 2024 · 0 comments

Comments

@PoltP
Copy link

PoltP commented Oct 30, 2024

I'm using your library like this

import * as React from 'react';
import {Suspense} from 'react';

const Spline = React.lazy(() => import('@splinetool/react-spline'));

export const Layout = React.memo(() => {
	return (
		<Suspense fallback={<div>Loading...</div>}>
			<Spline scene="........" />
		</Suspense>
	);
});

and my eslint generates the following error

    at new NodeError (node:internal/errors:387:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:365:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:589:7)
    at resolveExports (node:internal/modules/cjs/loader:556:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:596:31)
    at findModulePath (/myproject/node_modules/eslint-import-resolver-alias/index.js:99:27)
    at Object.exports.resolve (/myproject/node_modules/eslint-import-resolver-alias/index.js:75:10)
    at withResolver (/myproject/node_modules/eslint-module-utils/resolve.js:180:23)
    at fullResolve (/myproject/node_modules/eslint-module-utils/resolve.js:201:22)
    at relative (/myproject/node_modules/eslint-module-utils/resolve.js:217:10)  import/no-unresolved
  1:1   error    Resolve error: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /myproject/node_modules/@splinetool/react-spline/package.json

I can fix it locally adding default field into exports inside your package.json:

"exports": {
    ".": {
      "types": "./dist/Spline.d.ts",
      "import": "./dist/react-spline.js",
      "default": "./dist/react-spline.js"
    },
    "./next": {
      "types": "./dist/next/SplineNext.d.ts",
      "import": "./dist/react-spline-next.js",
      "default": "./dist/react-spline-next.js"
    }
  },

Unfortunately, it is not a good way to fix it in our common repository.

I cannot find a way to skip it for eslint and looks like it can be fixed on your side changing package.json.

Please help me to solve 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

1 participant