Create-react-app: npm install -g create-react-app fails

Created on 16 Apr 2018  ·  5Comments  ·  Source: facebook/create-react-app

I am trying to create a new react project with

npm install -g create-react-app create-react-app my-app

but I get an error as such :

[3/4] Linking dependencies...
[4/4] Building fresh packages...
[1/1] ⡀ uglifyjs-webpack-plugin
[-/1] ⡀ waiting...
[-/1] ⡀ waiting...
[-/1] ⡀ waiting...
error C:\Users\shaha\my-app\node_modules\uglifyjs-webpack-plugin: Command failed.
Exit code: 1
Command: node lib/post_install.js
Arguments:
Directory: C:\Users\shaha\my-app\node_modules\uglifyjs-webpack-plugin
Output:
internal/modules/cjs/loader.js:550
throw err;
^

Error: Cannot find module 'C:\Users\shaha\my-app\node_modules\uglifyjs-webpack-plugin\lib\post_install.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
at Function.Module._load (internal/modules/cjs/loader.js:475:25)

I am using NPM version

C:\Users\shaha>npm --version
5.6.0

and since it installs all the dependencies , it is painstaking for me to go through every configuration manually with yarn

same deal is faced with

npx create-react-app my-app

could you help me overcome this issue ?

Most helpful comment

Can you check if this npx -p create-react-app -c "create-react-app my-app --use-npm" works for you?

All 5 comments

Can you check if this npx -p create-react-app -c "create-react-app my-app --use-npm" works for you?

and since it installs all the dependencies , it is painstaking for me to go through every configuration manually with yarn

I don't understand what this means.

If you're experiencing npm bugs, you can install Yarn. Then you can run yarn create react-app myapp and it will use Yarn automatically.

Unfortunately we can't fix npm bugs. What you describe looks like one.

Yarn has also failed me

C:\Users\shaha\Desktop>yarn create react-app zxc
yarn create v1.6.0
[1/4] Resolving packages...
[2/4] Fetching packages...
warning Pattern ["object-assign@latest"] is trying to unpack in the same destination "C:\Users\shaha\AppData\Local\Yarn\Cache\v1\
pm-object-assign-4.1.1-2109adc7965887cfc05cbbd442cac8bfbb360863" as pattern ["object-assign@^4.1.0","object-assign@^4"]. This could result in non-deterministic behavior, skipping.
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "[email protected]" with binaries:
- create-react-app
[#############################################################################################################] 296/296internal/modules/cjs/loader.js:550
throw err;
^

Error: Cannot find module 'commander'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
at Function.Module._load (internal/modules/cjs/loader.js:475:25)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
at Object. (C:\Users\shaha\AppData\Local\Yarn\Data\global\node_modules\create-react-app\createReactApp.js:39:19)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
error Command failed.
Exit code: 1
Command: C:\Users\shaha\AppData\Local\Yarn\bin\create-react-app
Arguments: zxc
Directory: C:\Users\shaha\Desktop
Output:

info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.

Can you check if this npx -p create-react-app -c "create-react-app my-app --use-npm" works for you?

This actually worked , Wow , I am amazed , I had 0 expectation

I had another weird error with create-react-app breaking down. Confirming - That command worked! Wonderful! Thank you very much.

Was this page helpful?
0 / 5 - 0 ratings