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

Crash during parcel launch: _semver(...).default.minVersion is not a function #6720

Closed
szagi3891 opened this issue Aug 14, 2021 · 9 comments
Closed

Comments

@szagi3891
Copy link

szagi3891 commented Aug 14, 2021

🐛 bug report

I tried to run parcel2 in an existing project. When trying to run, the parcel crashes on a runtime error in one of its libraries.

🎛 Configuration (.babelrc, package.json, cli command)

package.json

{
  "name": "gpp-backoffice",
  "version": "1.1.1",
  "description": "frontend app for admin and traders",
  "dependencies": {
    "@types/react": "^17.0.17",
    "@types/react-dom": "^17.0.9",
    "parcel": "^2.0.0-rc.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  },
  "browserslist": [
    "last 3 iOS versions",
    "last 3 ChromeAndroid versions",
    "last 3 Chrome versions",
    "last 3 firefox versions",
    "last 3 safari versions",
    "last 3 Edge versions"
  ],
  "devDependencies": {
    "@parcel/transformer-image": "^2.0.0-rc.0"
  }
}

🤔 Expected Behavior

I wanted the parcel to run in my project

😯 Current Behavior

MacBook-Pro-Grzegorz:gpp-backoffice-3 grzegorzszeliga$ yarn run parcel serve ./src/index.html
yarn run v1.22.4
warning package.json: No license field
$ /Users/grzegorzszeliga/Desktop/Projekty/gpp-backoffice-3/node_modules/.bin/parcel serve ./src/index.html
Server running at http://localhost:1234
🚨 Build failed.

@parcel/transformer-js: _semver(...).default.minVersion is not a function

  TypeError: _semver(...).default.minVersion is not a function
  at loadConfig (/Users/grzegorzszeliga/Desktop/Projekty/gpp-backoffice-3/node_modules/@parcel/transformer-js/lib/JSTransformer.js:223:127)
  at async loadPluginConfig (/Users/grzegorzszeliga/Desktop/Projekty/gpp-backoffice-3/node_modules/@parcel/core/lib/requests/ConfigRequest.js:65:21)
  at async Transformation.loadTransformerConfig (/Users/grzegorzszeliga/Desktop/Projekty/gpp-backoffice-3/node_modules/@parcel/core/lib/Transformation.js:520:5)
  at async Transformation.loadPipeline (/Users/grzegorzszeliga/Desktop/Projekty/gpp-backoffice-3/node_modules/@parcel/core/lib/Transformation.js:459:20)
  at async Transformation.loadNextPipeline (/Users/grzegorzszeliga/Desktop/Projekty/gpp-backoffice-3/node_modules/@parcel/core/lib/Transformation.js:498:24)
  at async Transformation.runPipelines (/Users/grzegorzszeliga/Desktop/Projekty/gpp-backoffice-3/node_modules/@parcel/core/lib/Transformation.js:268:24)
  at async Transformation.run (/Users/grzegorzszeliga/Desktop/Projekty/gpp-backoffice-3/node_modules/@parcel/core/lib/Transformation.js:167:19)
  at async Child.handleRequest (/Users/grzegorzszeliga/Desktop/Projekty/gpp-backoffice-3/node_modules/@parcel/workers/lib/child.js:217:9)

💁 Possible Solution

There is probably a bad reference in the parcel code that was not detected by the static analysis.

function _semver() {
  const data = _interopRequireDefault(require("semver"));

  _semver = function () {
    return data;
  };

  return data;
}
_semver().default.minVersion(reactLibVersion)

Probably the "minVersion" method has been removed from the "semver" library.

🔦 Context

An error occurs during start-up

💻 Code Sample

It' s going to be hard for me to provide some example code, because this is a big project

🌍 Your Environment

Software Version(s)
Parcel ^2.0.0-rc.0
Node v14.17.4
npm/Yarn yarn 1.22.4
Operating System MacBook Pro
@szagi3891 szagi3891 changed the title _semver(...).default.minVersion is not a function Crash during parcel launch: _semver(...).default.minVersion is not a function Aug 14, 2021
@szagi3891
Copy link
Author

@devongovett - I see that you wrote the vast majority of this file 'packages/transformers/js/src/JSTransformer.js'. If I may make a suggestion, it is better not to make such large functions. Such code is a bit more difficult to maintain. Such a huge function is better broken down into several smaller functions.

@szagi3891
Copy link
Author

I removed node_modules and reinstalled it and it worked

@alextrastero
Copy link

alextrastero commented Oct 20, 2021

Same issue is happening to me, tried deleting node_modules AND clearing npm cache but issue still happens

  "devDependencies": {
    "@babel/cli": "^7.8.4",
    "@babel/core": "^7.15.8",
    "@babel/preset-react": "^7.9.4",
    "babel-core": "^7.0.0-bridge.0",
    "babel-jest": "^27.3.1",
    "babel-loader": "^8.1.0",
    "parcel": "^2.0.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  },
node: v12.22.6
npm: 6.14.15
OS: Pop!_OS 21.04 x86_64
> parcel build

🚨 Build failed.

@parcel/transformer-js: _semver(...).default.minVersion is not a function

  TypeError: _semver(...).default.minVersion is not a function
  at loadConfig (/home/proj/node_modules/@parcel/transformer-js/lib/JSTransformer.js:222:127)
  at async loadPluginConfig (/home/proj/node_modules/@parcel/core/lib/requests/ConfigRequest.js:65:21)
  at async Transformation.loadTransformerConfig (/home/proj/node_modules/@parcel/core/lib/Transformation.js:533:5)
  at async Transformation.loadPipeline (/home/proj/node_modules/@parcel/core/lib/Transformation.js:472:20)
  at async Transformation.run (/home/proj/node_modules/@parcel/core/lib/Transformation.js:169:20)
  at async Child.handleRequest (/home/proj/node_modules/@parcel/workers/lib/child.js:217:9)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! proj@3.10.0 build: `parcel build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the proj@3.10.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/proj/.npm/_logs/2021-10-20T12_28_05_916Z-debug.log

@bahmutov
Copy link

Same, just experienced the crash even with uninstall / install

$ node -v
v16.13.0
$ npm -v
8.1.3

@mischnic
Copy link
Member

Could someone share a github repo/zip where this happens? You can probably remove all of your project's code and leave just some dummy code file, package.json and the lockfile.

@danousna
Copy link

Had the same issue. Removing the package-lock.json file (and node_modules) seems to fix it... 🤷

@benwaffle
Copy link

@benwaffle
Copy link

The fix is npm i semver@5.7

parcel uses semver's minVersion method, which was introduced in 5.7 (https://git.io/J1KX4)

but parcel depends on semver 5.5:

❯ npm ls semver
aws-credentials-broker@0.0.1 /Users/ben/dev/aws-credentials-broker
└─┬ parcel@2.0.1
  ├─┬ @parcel/config-default@2.0.1
  │ ├─┬ @parcel/transformer-babel@2.0.1
  │ │ ├─┬ @babel/core@7.16.0
  │ │ │ └── semver@6.3.0
  │ │ ├─┬ @babel/helper-compilation-targets@7.16.3
  │ │ │ └── semver@6.3.0
  │ │ └── semver@5.7.1
  │ ├─┬ @parcel/transformer-css@2.0.1
  │ │ └── semver@5.5.1 deduped
  │ ├─┬ @parcel/transformer-html@2.0.1
  │ │ └── semver@5.5.1 deduped
  │ ├─┬ @parcel/transformer-js@2.0.1
  │ │ └── semver@5.5.1 deduped
  │ ├─┬ @parcel/transformer-postcss@2.0.1
  │ │ └── semver@5.5.1 deduped
  │ ├─┬ @parcel/transformer-posthtml@2.0.1
  │ │ └── semver@5.5.1 deduped
  │ └─┬ @parcel/transformer-svg@2.0.1
  │   └── semver@5.5.1 deduped
  ├─┬ @parcel/core@2.0.1
  │ └── semver@5.5.1
  └─┬ @parcel/package-manager@2.0.1
    ├─┬ cross-spawn@6.0.5
    │ └── semver@5.5.1 deduped
    └── semver@5.5.1 deduped

@mischnic
Copy link
Member

@benwaffle Great find! This should fix that #7334

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

6 participants