0

I just got a Mac Mini M1 for personal use, and I'm trying to run a preexisting React app. I installed nodejs and npm successfully, and running npm install does add the node_modules folder correctly as far as I can tell; but whenever I run npm start or npm run <script>, I get an error. It seems that npm can't access any of the project's dependencies. I've tried this using the rosetta terminal as well with the same results.

For an example, I initialized a new React project with npx create-react-app test_app, then cded into it and ran npm start. I got:

test_repo@0.1.0 start
> react-scripts start

sh: react-scripts: command not found

How do I get these commands to run properly and launch the app?

Here's what I'm using for node and npm:

➜  test_repo npm -v
7.6.0
➜  test_repo node -v
v15.11.0
Jamie Sauve
  • 270
  • 1
  • 4
  • 20
  • possibly the "react-scripts" app is not installed globally. Could you please install it with `npm i -g react-scripts` command ? – NIKHIL C M Mar 12 '21 at 03:12

1 Answers1

0

I found a (very) hacky solution for now. I'm no expert with npm, but what I discovered is that npm scripts refer to dependencies indirectly - for example, having a command that says

"test": "jest"

tells npm to look in node_modules/.bin for a file called jest and to run that. the issue is something to do with npm understanding this. But it's possible to get around that by putting the address of each dependency in the script, for example:

"test" "node_modules/.bin/jest"

I was able to get things to build this way. If someone comes along with a better answer, please show me up :P

Jamie Sauve
  • 270
  • 1
  • 4
  • 20