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

@wordpress/create-block throws TypeError: Invalid Version: 0.32 #28965

Closed
raaaahman opened this issue Feb 12, 2021 · 6 comments
Closed

@wordpress/create-block throws TypeError: Invalid Version: 0.32 #28965

raaaahman opened this issue Feb 12, 2021 · 6 comments
Labels
Needs Testing Needs further testing to be confirmed. [Tool] Create Block /packages/create-block

Comments

@raaaahman
Copy link

Description

While trying to follow the Create a block tutorial, I ran into an issue trying to use the command npx @wordpress/create-block starter-block.

Step-by-step reproduction instructions

  1. Type the following command in a terminal: npx @wordpress/create-block starter-block

OR

  1. Type the following command in a terminal: npm init @wordpress/block tutorial-block

Expected behaviour

I expected to scaffold a WordPress plugin directory with a custom block.

Actual behaviour

I had the following issue:

npx : 226 installé(s) en 12.698s
/home/sylvain/.npm/_npx/14594/lib/node_modules/@wordpress/create-block/node_modules/check-node-version/node_modules/semver/semver.js:323
throw new TypeError('Invalid Version: ' + version)
^

TypeError: Invalid Version: 0.32
at new SemVer (/home/sylvain/.npm/_npx/14594/lib/node_modules/@wordpress/create-block/node_modules/check-node-version/node_modules/semver/semver.js:323:11)
at SemVer (/home/sylvain/.npm/_npx/14594/lib/node_modules/@wordpress/create-block/node_modules/check-node-version/node_modules/semver/semver.js:313:12)
at /home/sylvain/.npm/_npx/14594/lib/node_modules/@wordpress/create-block/node_modules/check-node-version/index.js:118:33
at module.exports (/home/sylvain/.npm/_npx/14594/lib/node_modules/@wordpress/create-block/node_modules/map-values/index.js:9:18)
at /home/sylvain/.npm/_npx/14594/lib/node_modules/@wordpress/create-block/node_modules/check-node-version/index.js:112:22
at end (/home/sylvain/.npm/_npx/14594/lib/node_modules/@wordpress/create-block/node_modules/run-parallel/index.js:21:15)
at done (/home/sylvain/.npm/_npx/14594/lib/node_modules/@wordpress/create-block/node_modules/run-parallel/index.js:25:10)
at each (/home/sylvain/.npm/_npx/14594/lib/node_modules/@wordpress/create-block/node_modules/run-parallel/index.js:31:7)
at /home/sylvain/.npm/_npx/14594/lib/node_modules/@wordpress/create-block/node_modules/run-parallel/index.js:41:43
at /home/sylvain/.npm/_npx/14594/lib/node_modules/@wordpress/create-block/node_modules/check-node-version/index.js:59:14

I can't figure out which version this 0.32 refers to.

Code snippet (optional)

Here are the output of some commands:

$ node --version
v14.15.4
$ npm --version
6.14.11
$ nvm --version
0.33.11
$ npx --version
6.14.11
$ npm list -g --depth=0
/home/sylvain/.nvm/versions/node/v14.15.4/lib
├── @wordpress/[email protected]
├── [email protected]
└── [email protected]

Device information

  • Device: Desktop
  • Operating system: Ubuntu 18.04.5

Thanks!

@gziolo gziolo added [Tool] Create Block /packages/create-block Needs Testing Needs further testing to be confirmed. labels Feb 12, 2021
@gziolo
Copy link
Member

gziolo commented Feb 12, 2021

It should work with your versions of Node.js and npm. It's a very strange error that I see for the first time. Thank you for reporting!

@gziolo
Copy link
Member

gziolo commented Feb 15, 2021

I tried to reproduce with the exact same versions of node and npm. Everything finished without any issues. The only difference is that I use macOS Big Sur v11.2.1. It looks like it's OS-specific then.

@raaaahman
Copy link
Author

raaaahman commented Feb 17, 2021

Thank you for checking out.

Meanwhile, I have found the troublemaker, by running the command:

$ npx check-node-version --print
npx : 13 installé(s) en 1.685s
node: 14.15.4
npx: 6.14.11
yarn: given version not semver-compliant
npm: 6.14.11

It appears that yarn version was the causing the TypeError:

$ yarn --version
0.32

Except... it's not the right yarn! This yarn is part of the cmdtest debian package that is installed by default on Ubuntu 17, and 18 as it appears. A related issue.

So I had to uninstall it from my system (I don't plan on testing Unix commands in a near future):

$ sudo apt remove cmdtest

And now I am able to use @wordpress/create-block... At last!

I'm closing the issue, since this is not a problem with Gutenberg.

@gziolo
Copy link
Member

gziolo commented Feb 17, 2021

Thank you for reporting back your findings. I'm surprised that yarn is part of the validation when only npm and node are listed with minimum versions. Maybe we could find a way to skip that check.

@gziolo
Copy link
Member

gziolo commented Feb 17, 2021

I found where the issue comes from:

https://github.com/parshap/check-node-version/blob/e669f3223a5378d6d006af12c3da8e676dad559c/index.js#L98L101

It probably errored when checking the version of yarn as it iterates over all programs supported. In the latest version they fixed it - it only uses the listed programs. I will update the dependency.

@gziolo
Copy link
Member

gziolo commented Feb 17, 2021

I have a patch ready in #29066 that might improve things, thank you again @raaaahman 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Testing Needs further testing to be confirmed. [Tool] Create Block /packages/create-block
Projects
None yet
Development

No branches or pull requests

2 participants