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

Invalid Version: undefined #5943

Closed
LeoMsky opened this issue Mar 2, 2021 · 56 comments
Closed

Invalid Version: undefined #5943

LeoMsky opened this issue Mar 2, 2021 · 56 comments

Comments

@LeoMsky
Copy link

LeoMsky commented Mar 2, 2021

Everything is OK yesterday,but I've had this problem since I installed it again this morning
image

@skjb
Copy link

skjb commented Mar 2, 2021

FYI reverting to 1.12.3 seems to work

@DarinTayTwoXAR
Copy link

Pinning @babel/preset-env to 7.13.8 is what worked for me.

The version check that is failing here was added in 7.13.9 here - babel/babel@c155caf#diff-cddb13dc00454073d19373b40529b8047e25b9141ab627eb8be482601f16eabe

@vaibhavkumar-sf
Copy link

Yes, reverting to 1.12.3 is working

@bemnlam
Copy link

bemnlam commented Mar 2, 2021

Even a minimal repo with Parcel 1.12.4 installed does not work:

npm init -y && npm i parcel && touch index.js && echo "<html><body>Minimal Parcel<script src=\"./index.js\"></script></body></html>" > index.html

Add a dev command in package.json:

"scripts": {
  "dev": "parcel index.html"
},

And then run npm run dev. This is the error:

Server running at http://localhost:1234 
🚨  /Users/ben.lam/poc/testbuild/index.js: Invalid Version: undefined
    at new SemVer (/Users/ben.lam/poc/testbuild/node_modules/@babel/preset-env/node_modules/semver/semver.js:314:11)
    at compare (/Users/ben.lam/poc/testbuild/node_modules/@babel/preset-env/node_modules/semver/semver.js:647:10)
    at lt (/Users/ben.lam/poc/testbuild/node_modules/@babel/preset-env/node_modules/semver/semver.js:688:10)
    at /Users/ben.lam/poc/testbuild/node_modules/@babel/preset-env/lib/index.js:276:22
    at Object.default (/Users/ben.lam/poc/testbuild/node_modules/@babel/helper-plugin-utils/lib/index.js:22:12)
    at getEnvPlugins (/Users/ben.lam/poc/testbuild/node_modules/parcel/src/transforms/babel/env.js:62:34)
    at getEnvConfig (/Users/ben.lam/poc/testbuild/node_modules/parcel/src/transforms/babel/env.js:12:25)
    at async getBabelConfig (/Users/ben.lam/poc/testbuild/node_modules/parcel/src/transforms/babel/config.js:32:19)
    at async babelTransform (/Users/ben.lam/poc/testbuild/node_modules/parcel/src/transforms/babel/transform.js:6:16)
    at async JSAsset.pretransform (/Users/ben.lam/poc/testbuild/node_modules/parcel/src/assets/JSAsset.js:83:5)

Like the others, pinning Parcel to 1.12.3 in package.json can (temporarily) solve this problem. e.g.:

"dependencies": {
  "parcel": "1.12.3"
},

@jansiegel
Copy link

jansiegel commented Mar 2, 2021

This seems to be caused by an update to [email protected] and this change in particular: https://github.com/babel/babel/pull/12934/files#diff-cddb13dc00454073d19373b40529b8047e25b9141ab627eb8be482601f16eabeR301

It requires an object with a version field to be passed to presetEnv, while [email protected] doesn't to that: https://github.com/parcel-bundler/parcel/blob/parcel-bundler%401.12.4/packages/core/parcel-bundler/src/transforms/babel/env.js#L62

@wachunei
Copy link

wachunei commented Mar 2, 2021

It seems this bug is present on both v1 and v2 babel/babel#12945 (comment)

Although v1 is not maintained anymore, is it posssible to make an exception here and bump a patch in both version when the fix is available?

@dwanl
Copy link

dwanl commented Mar 2, 2021

Yes, I also had this problem

@nicolo-ribaudo
Copy link

You can workaround this by adding

"resolutions": {
  "@babel/preset-env": "7.13.8"
}

to your package.json file. With Yarn it will automatically download the previous @babel/preset-env version (which doesn't rely on the Babel API Parcel isn't providing); with npm you'll need https://www.npmjs.com/package/npm-force-resolutions to make it work.

@mmikhalko
Copy link

Please fix this bug ASAP

angeliquejw added a commit to angeliquejw/dev-blog that referenced this issue Mar 2, 2021
@angeliquejw
Copy link

The workaround posted by @nicolo-ribaudo worked for me; thanks, Nicolò!

@devongovett
Copy link
Member

devongovett commented Mar 2, 2021

I don't believe this occurs in Parcel 2 FWIW. The codepath linked in the babel issue is never hit: config.isSource is always true due to

if (!config.isSource) {
return;
}

@devongovett
Copy link
Member

devongovett commented Mar 2, 2021

I would encourage folks to try out v2 as it's much more stable and actively maintained whereas v1 has been unmaintained for some time. Personally, I don't use v1 in any of my projects anymore, and v2 is being used in production by some big companies like Adobe and Atlassian. While we are very close to a v2 release candidate, the best way for now is to pin to a recent nightly. If that doesn't work for you, you can try the workaround posted by @nicolo-ribaudo above.

@tad-lispy
Copy link

Prompted by this issue I just made a switch to v2 few hours ago and so far I'm very happy with it. I had a bit of trouble with compiling Elm, but eventually got it to work. See here for details: #5948

@saostad
Copy link

saostad commented Mar 2, 2021

I have this problem in v2 too.

@tiennv-fireapps
Copy link

I just install parcel global yesterday and applied these ways above,
but still get this error.

@leonsux
Copy link

leonsux commented Mar 3, 2021

same problem

@tienluckyfor
Copy link

yarn global add [email protected]
then run
parcel index.html
work for me!

@kappe
Copy link

kappe commented Mar 3, 2021

Server running at http://localhost:9999

🚨 /home/user/tmp/mist/src/index.js: Invalid Version: undefined
at new SemVer (/home/user/tmp/mist/node_modules/semver/semver.js:314:11)
at compare (/home/user/tmp/mist/node_modules/semver/semver.js:647:10)
at lt (/home/user/tmp/mist/node_modules/semver/semver.js:688:10)
at /home/user/tmp/mist/node_modules/@babel/preset-env/lib/index.js:276:22

we removed the semver statement inside the if clause
"resolutions" is not working

@mischnic mischnic changed the title parcel cannot run well again Invalid Version: undefined Mar 3, 2021
@Qix-
Copy link

Qix- commented Mar 3, 2021

@devongovett @mischnic Might I suggest pinning this until it's resolved; I imagine you're going to see a lot more duplicates.


I would encourage folks to try out v2

Works great aside from the fact none of the plugins work for it. I do appreciate the much more stable file watching. But it's a non-starter since nothing aside from the core bundler works. It doesn't even detect old packages with an error or anything, it just silently ignores them.

EDIT: Downgrading to 1.12.3 doesn't work for me. Nuking node_modules didn't change anything. I also have package-lock.json disabled and have exact versions enabled. parcel --version reports 1.12.3. I'm still getting the same message.


<rant>

This isn't targeted at the Parcel devs in particular, though I'm getting really tired of having to have the "semver ranges are evil" talk and getting told I don't know what I'm talking about. 10 years later and these utopian views of perfect versioning semantics haven't panned out.
</rant>

To summarize #5943 (comment) for NPM users:

  1. Make sure package-lock.json is enabled. If you have it disabled via e.g. .npmrc, remove that config line and add an entry into .gitignore if you must. It's required for this fix to work.
  2. Add "preinstall": "npx npm-force-resolutions" to your scripts in package.json
  3. Add the resolutions block to the root of package.json, e.g.:
{
  "name": "my-package",
  "scripts": {
    "preinstall": "npx npm-force-resolutions"
  },
  "resolutions": {
    "@babel/preset-env": "7.13.8"
  }
}
  1. If you have NOT already installed your node_modules, run npm i twice. This is because the first install only modifies the package-lock.json entry, but doesn't tell npm to actually install it. The second run will make npm see the pinned dependency edits and pull the correct version.

Note that this workaround only works at the top level; you cannot employ this as a library as it won't work for downstream consumers of your library. There's no workaround in such cases.

@devongovett
Copy link
Member

@Qix- Which plugins in particular are you interested in?

rickstaa added a commit to rickstaa/react-use-user-media that referenced this issue Oct 26, 2021
This commit adds the typescript declaration file. It further upgrades
parcel to version 2. This needed to be done to get rid of the `Invalid
Version: undefined` error (see
parcel-bundler/parcel#5943).
rickstaa added a commit to rickstaa/react-use-user-media that referenced this issue Oct 26, 2021
This commit adds the typescript declaration file. It further upgrades
parcel to version 2. This needed to be done to get rid of the `Invalid
Version: undefined` error (see
parcel-bundler/parcel#5943).
rickstaa added a commit to rickstaa/react-use-user-media that referenced this issue Oct 26, 2021
This commit adds the typescript declaration file. It further upgrades
parcel to version 2. This needed to be done to get rid of the `Invalid
Version: undefined` error (see
parcel-bundler/parcel#5943).
rickstaa added a commit to rickstaa/react-use-user-media that referenced this issue Oct 26, 2021
This commit adds the typescript declaration file. It further upgrades
parcel to version 2. This needed to be done to get rid of the `Invalid
Version: undefined` error (see
parcel-bundler/parcel#5943).
rickstaa added a commit to rickstaa/react-use-user-media that referenced this issue Oct 26, 2021
This commit adds the typescript declaration file. It further upgrades
parcel to version 2. This needed to be done to get rid of the `Invalid
Version: undefined` error (see
parcel-bundler/parcel#5943). While doing so I
also had to change the react import in the `example/index.js` due to a parcel
bug (see parcel-bundler/parcel#1199).
louh added a commit to streetmix/streetmix that referenced this issue Jan 9, 2022
The @babel/preset-env package starting at v7.13.9 and above will throw a
"Invalid Version: undefined" error on build time, as a result of a conflict
with parcel-bundler v1. See discussion here:

parcel-bundler/parcel#5943

There is no fix in Parcel v1, so @babel/preset-env should be pegged here
until Parcel is upgraded to v2 or another solution is found.
louh added a commit to streetmix/streetmix that referenced this issue Jan 9, 2022
The @babel/preset-env package starting at v7.13.9 and above will throw a
"Invalid Version: undefined" error on build time, as a result of a conflict
with parcel-bundler v1. See discussion here:

parcel-bundler/parcel#5943

There is no fix in Parcel v1, so @babel/preset-env should be pegged here
until Parcel is upgraded to v2 or another solution is found.
@Velodata
Copy link

Velodata commented Feb 3, 2022

Came across this problem myself today while trying to run a two year old tutorial regarding React.js and Wordpress.

After much poking and prodding I discovered that it helps to clear your npm cache files. It seems that once you download the wrong version of @babel (at least in the context of the problem defined in this thread) then that is the version which keeps getting loaded into your node-modules directory.

@AjiteshMDK
Copy link

Getting the same error. can anyone please help me on fixing it? already have followed all the solution mentioned here, still no luck. any help on this would be great.

image

Git repo -
AjiteshMDK/GeoLocation-Update#1

panlina added a commit to panlina/express-site-admin that referenced this issue Feb 23, 2022
@SerzhLe
Copy link

SerzhLe commented Apr 10, 2022

FYI reverting to 1.12.3 seems to work

Yes! Try to downgrade to this version. I used v.1.12.4. I have spent half a day finding a solution - and only this switching worked for me!

Migheli pushed a commit to Migheli/star-burger that referenced this issue Mar 8, 2023
Pavel2232 pushed a commit to Pavel2232/star-burger that referenced this issue Jul 26, 2023
jackerghan added a commit to jackerghan/speedscope that referenced this issue Sep 1, 2023
adamretter added a commit to evolvedbinary/prosemirror-lwdita that referenced this issue Apr 12, 2024
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