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

Could not find module "@babel/core", but it was listed in package.json. Run your package manager first. #9040

Closed
0x1af2aec8f957 opened this issue May 26, 2023 · 5 comments 路 Fixed by #9049

Comments

@0x1af2aec8f957
Copy link

0x1af2aec8f957 commented May 26, 2023

I upgraded parcel to 2.9.0 and encountered the following error:

yarn run v1.22.19
$ cross-env NODE_OPTIONS=--max-old-space-size=16384 parcel build ./public/index.html --no-cache --no-source-maps --log-level='error' --dist-dir='./build'
馃毃 Build failed.

@parcel/package-manager: Could not find module "@babel/core", but it was listed in package.json. Run your package manager first.

  @WorkDir/package.json:38:5
    37 |   "devDependencies": {
  > 38 |     "@babel/core": "^7.22.0",
  >    |     ^^^^^^^^^^^^^ Defined here, but not installed
    39 |     "@babel/preset-env": "^7.22.0",
    40 |     "@parcel/config-default": "^2.9.0",

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The same configuration restricting the version to 2.8.0 can work normally.

My .parcelrc:

{
  "extends": "@parcel/config-default",
  "validators": {
    "*.{ts,tsx}": ["@parcel/validator-typescript"]
  },
  "resolvers": ["@parcel/resolver-glob", "..."],
  "transformers": {
    // "*.{js,mjs,jsx,cjs,ts,tsx}": [
    //   "@parcel/transformer-js",
    //   "@parcel/transformer-react-refresh-wrap"
    // ]
  }
}

Can anyone tell what happened? I made sure I have all dependencies installed and found.

@mischnic
Copy link
Member

The underlying error is

Resolving: @babel/types
From: node_modules/@babel/core/lib/transformation/file/file.js
Result:{
  ...
  error: {
    type: 'JsonError',
    path: 'node_modules/@babel/types/lib/package.json',
    line: 1,
    column: 18,
    message: 'unknown variant `script`, expected one of `commonjs`, `module`, `json` at line 1 column 18'
  },
}

https://unpkg.com/browse/@babel/types@7.22.0/lib/package.json

@mellodev
Copy link

Following, as I have a similar issue with 2.9.0 and babel after upgrading my working 2.8.2 project:

@parcel/transformer-babel: Could not resolve module "@babel/types" from ".../node_modules/.pnpm/@babel+core@7.22.1/node_modules/@babel/core/lib/transformation/file/file.js"

image

@devongovett
Copy link
Member

devongovett commented May 27, 2023

Looks like this was introduced in Babel 7.22 which was just released today as well. Opened babel/babel#15664

@nicolo-ribaudo
Copy link

nicolo-ribaudo commented May 27, 2023

Fixed in @babel/types@7.22.3 and @babel/core@7.22.1.

@mellodev
Copy link

mellodev commented May 27, 2023

Thank you @nicolo-ribaudo! Confirmed worked now with Parcel 2.9.0 and the following Babel deps (for my project requirements):

  • "@babel/core": "7.22.1",
  • "@babel/types": "7.22.3",
  • "@babel/plugin-proposal-class-properties": "7.18.6",
  • "@babel/plugin-proposal-object-rest-spread": "7.20.7",
  • "@babel/plugin-transform-object-assign": "7.18.6",
  • "@babel/preset-env": "7.22.2",
  • "@babel/preset-react": "7.22.3",
  • "@babel/preset-typescript": "7.21.5",

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

Successfully merging a pull request may close this issue.

5 participants