Try this for NPM Build Setup Errors in Your Local WordPress Development Environment

posted in: Designer 0

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.

Hey, making custom theme default colors is fun, but lets automate these updates with Node Package Manager builds.
Hey, making custom theme default colors is fun, but lets automate these updates with Node Package Manager builds.

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:

https://www.youtube.com/watch?v=jwIpsW3UoUI&list=PLriKzYyLb28lHhftzU7Z_DJ32mvLy4KKH&index=4

I was enabling Node auto builds for a local WordPress install per this nice YouTube tutorial. But it wasn’t working until I tried:

  1. add "@wordpress/scripts": "^3.1.0", to the "DevDependencies{}" section of the package.json file,
  2. and then re-run the npm run build:scripts command from terminal.
PACKAGE JSON FILE FOR WORDPRESS LOCAL DEVELOPMENT-ERROR MESSAGE
PACKAGE JSON FILE FOR WORDPRESS LOCAL DEVELOPMENT-ERROR MESSAGE

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:

  1. npm audit fix command from terminal,
  2. then close your text editor (after it’s done auditing), restart it,
  3. try running npm run build:scripts again to see if it works.
PACKAGE JSON FILE FOR WORDPRESS LOCAL DEVELOPMENT-ERROR MESSAGE 2
PACKAGE JSON FILE FOR WORDPRESS LOCAL DEVELOPMENT-ERROR MESSAGE 2

If that doesn’t do it, I’m out of ideas, Sorry!

Node Package Manager auto build for wordpress local dev environment NOT erroring out
Node Package Manager auto build for wordpress local dev environment NOT erroring out

Leave a Reply about how this blog changed your life.