1

I am an amateur programmer. I've played with varoius languages over the years but php is the one I know best and often reach for even when I'm sure a real programmer would say I'm using the wrong tool.

I had a developer build a wordpress site for me with a custom theme. I have subsequently written a couple of plugins in pure php that work just fine.

I am now wishing to add another plugin for my site that is going to require a little more frontend trickery. The last time I did anything like this was long before reactjs existed and I cannot remember much javascript - however I was able to master some ajax with php and have old code I can look at to remind myself.

I have installed node and then react on my windows laptop and have built a few hello-world apps. But I now want to write a plugin that will work on my wordpress install.

I am trying to follow this tutorial https://www.green-box.co.uk/create-a-wordpress-plugin-that-uses-a-react-app/. It says that a prerequisite is to have node installed - which I have done on my plesk server by following the instructions for adding it through the "add/remove components" of my plesk web interface, rather than over command line.

Now when I SSH to my server, cd to the /wp-content/plugins/helloworld/ and type npm create-react-app helloworld I get the error:

nodenv: npm: command not found

The `npm' command exists in these Node versions:
  12
  14
  16
  18

I think I'm fundamentally misunderstanding how reactjs works but can't seem to get my head round what to do. Have I got the 'wrong' node installed? Or am I supposed to build the code on my local machine and somehow compile it and upload to my web server? Last time I used javascript it was just dumped in plain text files and referened in the html header like css files. I'm sure it's all quite simple but I'm wondering if I shouldn't just ditch the idea of learning any react and doing it all with vanilla javascript.

Could any of the wise heads out there point me in the right direction with a clue? I'm too old for all this new-fangled techology I'm sure this is how my dad felt when they invented cellphones :(

0 Answers0