3

I'm setting up a local environment for the React Tutorial and I'm having some issues.

What version of node do I have?

$ node -v
v10.10.0

Set up the tutorial environnment

$ npm install -g create-react-app
/opt/nodejs/bin/create-react-app -> /opt/nodejs/lib/node_modules/create-react-app/index.js
+ create-react-app@1.5.2
added 67 packages from 20 contributors in 9.879s

Execute the instructions for tutorial setup:

$ npx create-react-app my-app
-bash: npx: command not found

What?! is npx missing?

$ npx 
-bash: npx: command not found

Hmm. Use this solution (npx command not working):

$ npm i -g npx
/opt/nodejs/bin/npx -> /opt/nodejs/lib/node_modules/npx/index.js
+ npx@10.2.0
added 484 packages from 651 contributors in 34.539s

It's installed? For sure?

$ whereis npx
npx: /opt/nodejs/bin/npx

Right. I don't trust you. What's in that directory?

$ v /opt/nodejs/bin/
total 34468
lrwxrwxrwx 1 kingram kingram       45 Sep 17 17:04 create-react-app -> ../lib/node_modules/create-react-app/index.js
-rwxr-xr-x 1 xxxxxxx xxxxxxx 35291184 Sep  6 13:15 node
lrwxrwxrwx 1 xxxxxxx xxxxxxx       38 Sep  6 13:15 npm -> ../lib/node_modules/npm/bin/npm-cli.js
lrwxrwxrwx 1 xxxxxxx xxxxxxx       32 Sep 17 17:10 npx -> ../lib/node_modules/npx/index.js

Something looks wrong about that.

$ npx -v
-bash: npx: command not found

Back to the beginning. Maybe it's not built that way.

$ npx create-react-app my-app
-bash: npx: command not found

I was right not to trust you.

So. Any thoughts from experienced users?

ADDITIONAL INFO:

NPM version

$ npm -v
6.4.1

Where is npm?

$ which npm
/usr/bin/npm

"...you should be able to execute create-react-app on its own without the npx prefix..."

$ create-react-app my-app    
-bash: create-react-app: command not found
Ken Ingram
  • 1,538
  • 5
  • 27
  • 52
  • Can you execute `which npm` and report the result? – Phil Sep 18 '18 at 00:42
  • 1
    Also, you _should_ be able to execute `create-react-app` on its own without the `npx` prefix – Phil Sep 18 '18 at 00:43
  • What is your `npm` version? You need [at least 5.2](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) to have `npx` – Phil Sep 18 '18 at 00:44
  • 1
    can you share your OS and version? – Viet Sep 18 '18 at 01:26
  • 1
    Can you check if `/usr/bin/npm` is a symlink to the one in `/opt`. It really just sounds like your `PATH` environment variable doesn't include `/opt/nodejs/bin/`. What does `echo $PATH` show? – Phil Sep 18 '18 at 02:33
  • Good call @Phil4 (lrwxrwxrwx 1 root root 21 Sep 14 16:21 /usr/bin/npm -> /etc/alternatives/npm) – Ken Ingram Sep 18 '18 at 07:02

0 Answers0