I’m posting this because it took me a while to figure out, so hopefully it takes you less time. If you’re seeing “wp-scripts is not recognized as an internal or external command
” errors, read on.
Let’s Automate Script Rebuilds in Local WordPress Development Environment using Node Package Manager (NPM)
I wanted to automate rebuilds upon changes made to JavaScript files in my local WordPress development environment–that way I can see the effect of every little change to my code in real time. But trying to get the build command to work was only producing errors, like "wp-scripts is not recognized as an internal or external command"
Good YouTube Tutorial for setting up NPM local WordPress dev environment refreshing:
I was enabling Node auto builds for a local WordPress install per this nice YouTube tutorial. But it wasn’t working until I tried:
- add
"@wordpress/scripts": "^3.1.0",
to the"DevDependencies{}"
section of thepackage.json
file, - and then re-run the
npm run build:scripts
command from terminal.
I don’t know why my package.json
file was missing that particular devDependency
, but it was. If that didn’t fix it for you, try running the:
npm audit fix
command from terminal,- then close your text editor (after it’s done auditing), restart it,
- try running
npm run build:scripts
again to see if it works.
If that doesn’t do it, I’m out of ideas, Sorry!