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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Cannot find package '@babel/plugin-preset-typescript' when using @babel/preset-typescript #16244

Closed
1 task
MrDiamondDog opened this issue Jan 29, 2024 · 2 comments
Labels
i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@MrDiamondDog
Copy link

馃捇

  • Would you like to work on a fix?

How are you using Babel?

@babel/cli

Input code

index.tsx

function Component() {
    const [state, setState] = useState(0);
    return <button onClick={() => setState(state + 1)}>{state}</button>;
}

Command used to run
npx babel index.tsx

Configuration file name

babel.config.json, .babelrc

Configuration

{
    "plugins": ["@babel/preset-typescript"]
}

Current and expected behavior

It keeps throwing this error for no reason, I have no clue why, and I can't find any issues relating to this anywhere.

Full Error:

Error: Cannot find package '@babel/plugin-preset-typescript' imported from /home/mrdiamond/Documents/Workspace/custom-jsx/babel-virtual-resolve-base.js
    at new NodeError (/home/mrdiamond/Documents/Workspace/custom-jsx/node_modules/.pnpm/@babel+core@7.23.7/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:194:5)
    at packageResolve (/home/mrdiamond/Documents/Workspace/custom-jsx/node_modules/.pnpm/@babel+core@7.23.7/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:908:9)
    at moduleResolve (/home/mrdiamond/Documents/Workspace/custom-jsx/node_modules/.pnpm/@babel+core@7.23.7/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:937:20)
    at defaultResolve (/home/mrdiamond/Documents/Workspace/custom-jsx/node_modules/.pnpm/@babel+core@7.23.7/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:1007:15)
    at resolve (/home/mrdiamond/Documents/Workspace/custom-jsx/node_modules/.pnpm/@babel+core@7.23.7/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:1020:12)
    at tryImportMetaResolve (/home/mrdiamond/Documents/Workspace/custom-jsx/node_modules/.pnpm/@babel+core@7.23.7/node_modules/@babel/core/lib/config/files/plugins.js:142:45)
    at resolveStandardizedNameForImport (/home/mrdiamond/Documents/Workspace/custom-jsx/node_modules/.pnpm/@babel+core@7.23.7/node_modules/@babel/core/lib/config/files/plugins.js:164:19)
    at resolveStandardizedName (/home/mrdiamond/Documents/Workspace/custom-jsx/node_modules/.pnpm/@babel+core@7.23.7/node_modules/@babel/core/lib/config/files/plugins.js:173:22)
    at loadPlugin (/home/mrdiamond/Documents/Workspace/custom-jsx/node_modules/.pnpm/@babel+core@7.23.7/node_modules/@babel/core/lib/config/files/plugins.js:52:20)
    at loadPlugin.next (<anonymous>) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Environment

  • Babel CLI: 7.23.9
  • Babel TS Preset: 7.23.3
  • OS: Ubuntu
  • Node: 18.18.2
  • pnpm: 8.11.0

Possible solution

No response

Additional context

No response

@babel-bot
Copy link
Collaborator

Hey @MrDiamondDog! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

@MrDiamondDog
Copy link
Author

Oops, simple fix:

{
    "plugins": ["@babel/preset-typescript"]
}

Should be

{
    "presets": ["@babel/preset-typescript"]
}

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Apr 30, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

2 participants