0

Im trying to install create-react-app but it throws me this error -

rem$ npm install -g create-react-app
Command failed: /bin/sh -c /usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js config get cache --parseable
/usr/local/lib/node_modules/npm/bin/npm-cli.js:82
      let notifier = require('update-notifier')({pkg})
      ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:414:25)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:136:18)
    at node.js:963:3

I updated both npm and node but still get the same problem.

brew upgrade npm brew upgrade node

rem$ brew upgrade npm
Error: npm 10.9.0 already installed
rem$ brew upgrade node
Error: node 10.9.0 already installed
user1050619
  • 19,822
  • 85
  • 237
  • 413
  • 1
    Your problem is specific to OS X and brew. You're running Node 4, despite what brew says. Try `node -v`. You may need something like that https://stackoverflow.com/a/27008484/3731501 . Why do you use `npx`? Calling `npm install -g create-react-app` directly should work. – Estus Flask Sep 01 '18 at 20:45
  • its a typo form cut n paste..I uninstalled my node and npm using BREW and then reinstalled it and it started working fine. – user1050619 Sep 01 '18 at 22:01

1 Answers1

0

I had similar trouble with npm. Although I had node 10, it was still defaulting to node@4. Then I installed nvm and used it install specific nodejs version and use it. On Mac,

curl https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash

export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" 
nvm install <specify nodejs version you require>
nvm use <specify version of nodejs> 
skr
  • 127
  • 2
  • 16