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

build with latest yarn throw error #3231

Open
ullaskunder1 opened this issue Jul 31, 2024 · 1 comment
Open

build with latest yarn throw error #3231

ullaskunder1 opened this issue Jul 31, 2024 · 1 comment

Comments

@ullaskunder1
Copy link

ullaskunder1 commented Jul 31, 2024

Current behavior:

When trying to compile a React project using @emotion/react, the following error occurs:

Resolve error: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './types/jsx-namespace' is not defined by "exports" in /node_modules/@emotion/react/package.json

To reproduce:

  1. Set up a React project with @emotion/react.
  2. Try to compile the project.

Expected behavior:

The project should compile without errors.

Environment information:

  • react version: 18.3.3
  • @emotion/react version: 11.11.0
  • yarn version: 4.3.1
  • node version: v20.15.1

Additional Information:

Code:

// package.json
"scripts": {
    "complie:dev": "dotenv -e .env.dev react-scripts build"
},
"devDependencies": {
    "@emotion/eslint-plugin": "^11.11.0",
    "@types/react": "^18.3.3",
    "@typescript-eslint/eslint-plugin": "^5.9.1",
    "@typescript-eslint/parser": "^5.9.1",
    "dotenv-cli": "^5.1.0",
    "eslint": "^8.6.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-prettier": "^8.5.0",
    "eslint-import-resolver-alias": "^1.1.2",
    "eslint-import-resolver-typescript": "^2.5.0",
    "eslint-plugin-import": "^2.25.4",
    "eslint-plugin-jsx-a11y": "^6.5.1",
    "eslint-plugin-prettier": "^4.2.1",
    "eslint-plugin-react": "^7.28.0",
    "eslint-plugin-react-hooks": "^4.3.0",
    "prettier": "^2.7.1",
    "react-app-rewired": "^2.2.1"
},
// tsconfig.json
{
    "compilerOptions": {
        "types": ["@emotion/react", "@emotion/react/types/jsx-namespace"],
        "target": "es5",
        "lib": ["dom", "dom.iterable", "esnext"],
        "allowJs": true,
        "skipLibCheck": true,
        "jsx": "react-jsx",
        "jsxImportSource": "@emotion/react",
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "strict": true,
        "forceConsistentCasingInFileNames": true,
        "noFallthroughCasesInSwitch": true,
        "module": "esnext",
        "moduleResolution": "node",
        "resolveJsonModule": true,
        "isolatedModules": true,
        "noEmit": true
    },
    "include": ["src"]
}
// React component example
import { ReactJSXElement } from '@emotion/react/types/jsx-namespace';
import { Navigate, useLocation } from 'react-router-dom';
import { AuthContext } from '../utils/Auth';

type Props = {
  children: ReactJSXElement;
};

@ENvironmentSet
Copy link
Contributor

ENvironmentSet commented Oct 2, 2024

You don't need to explicitly link emotion to typescript compilation steps. tsc will find type definitions itself.

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

No branches or pull requests

2 participants