Closed waviaei closed 3 years ago
Actually, infact, something is still not right, because npm run build
does not work.
npm run build
my-blocks@0.1.0 build wp-scripts build
sh: wp-scripts: command not found npm ERR! code 127 npm ERR! path /Users/toru/Sites/sandbox/my-blocks npm ERR! command failed npm ERR! command sh -c wp-scripts build
Hi @waviaei, sorry for the delay getting back to you, are you still experiencing the problem?
We discussed this issue in a slack triage session (https://wordpress.slack.com/archives/C02QB2JS7/p1620711271039900), and none of us could reproduce the problem, so I think it has since been solved.
There's now a new issue though, described in https://github.com/WordPress/gutenberg/issues/31361. That can be best worked around by using node 15 / npm 7, or by explicitly npm installing postcss
in the project after it has been created.
Hope that helps. I'll close this issue now.
@talldan Thank you for taking time in triaging the issue. I had a quick check, and same issue still occurred. However, update npm from 7.3 to 7.14 and it now seem to work. It does give Skipping "@wordpress/block-editor" npm dependency.
error, but it now do build.
I am currently not actively using create-block
so please keep the issue closed. Thanks!
This error occurred for me too: the solution was to run export NODE_ENV=development
first. If the NODE_ENV
isn't development
, the npm install
command doesn't install the development dependency @wordpress/scripts
. cc @talldan.
export NODE_ENV=development
I searched the ENTIRE internet and I was going crazy, Years of experience with npm
and pnpm
. To find that this is the solution.
You're a god send this evening lol. Thank you!
What is the reason for this issue @markhowellsmead?
Shouldn't npx @wordpress/create-block work out of the box?
I get the same error even for simpler commands like: npx @wordpress/create-block@latest todo-list
Not sure, sorry. I haven’t looked at it for over two years and the issue was closed in 2021. The tech. has doubtlessly moved on considerably since then.
And yet, the issue still happens 🙂 Thank you for the quick reply!
@giannis-dallas
Not an issue with @wordpress/create-block
, but my friend who develop themes using @wordpress/scripts/
, wp-env
, etc, had a weird situation where scripts do not build properly. It turns out that it was export NODE_ENV=development
that was written into his bash or zsh file -- same as @markhowellsmead . He suspects it was seem to be added by node version manager e.g. nvm, n, nodenv. He is not sure which, as he was testing/swapping around few.
It explains why the issue happens to some people and not to everyone. I can't be sure, but if you use node version manager, check for update, settings, etc.
Thank you, it worths taking a deeper look
Setting export NODE_ENV=development solved my problem, thank you very much @markhowellsmead
still experienced this error using nvm (installed on a fresh ubuntu 22.04 system this week), node v22.4.0, and 4.46.0 create-block.
Solved by adding NODE_ENV=development
to my .bashrc
Description
Used
npx @wordpress/create-block
to create a block, it fails. It will create package directories undernode_modules/
, but they are all empty inside.Step-by-step reproduction instructions
Just run
npx @wordpress/create-block
Expected behaviour
Creates block as per documented.
Note:
Some googling of "Error: Command failed with exit code 127" lead me to similar errors in Yarn package, where people suggesting "delete node_modules/ and do npm install again" -- this seem to solve though no sure why.
So I tried same, and this completed installation. Not sure why.
Anyhow,
npx @wordpress/create-block
should just work.Code snippet (optional)
Below is the output doing deletion of node modules and doing npm install.
Device information