facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.7k stars 26.84k forks source link

npx aborting creation #8896

Closed akctba closed 4 years ago

akctba commented 4 years ago

The npx command is aborting and doesn't create the application.

I'm using the command: npx create-react-app appexample

and at the end of the execution it prints:

Error [ERR_INVALID_PACKAGE_TARGET]: Invalid "exports" main target "index.js" defined in the package config /Users/alexkayser/git/apptest/node_modules/is-promise/package.json at resolveExportsTarget (internal/modules/cjs/loader.js:542:13) at resolveExportsTarget (internal/modules/cjs/loader.js:581:20) at applyExports (internal/modules/cjs/loader.js:455:14) at resolveExports (internal/modules/cjs/loader.js:508:23) at Function.Module._findPath (internal/modules/cjs/loader.js:632:31) at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1001:27) at Function.Module._load (internal/modules/cjs/loader.js:884:27) at Module.require (internal/modules/cjs/loader.js:1074:19) at require (internal/modules/cjs/helpers.js:72:18) at Object. (/Users/alexkayser/git/apptest/node_modules/run-async/index.js:3:17) { code: 'ERR_INVALID_PACKAGE_TARGET' }

Aborting installation. node has failed.

Deleting generated file... node_modules Deleting generated file... package.json

Versions

This is the versions of NPM and Node: npm --version
6.14.4

node --version
v14.0.0

(the problem is not experienced on node 12.12.0)

Which terms did you search for in User Guide?

npx create-react-app

Environment

Environment Info:

current version of create-react-app: 3.4.1 running from /usr/local/lib/node_modules/create-react-app

System: OS: macOS 10.15.4 CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz Binaries: Node: 14.0.0 - /usr/local/bin/node Yarn: Not Found npm: 6.14.4 - /usr/local/bin/npm Browsers: Chrome: 81.0.4044.122 Firefox: Not Found Safari: 13.1 npmPackages: react: Not Found react-dom: Not Found react-scripts: Not Found npmGlobalPackages: create-react-app: 3.4.1

Steps to reproduce

A simple new app creation:

1.run the command: npx react-create-app somenamehere 2.it aborts and delete the files

Expected behavior

Expected to create a new react app.

Actual behavior

It's not creating a new react app.

sabin2000pro commented 4 years ago

@sabinlungudotcpp You need to install nvm to use that command

Yeah, or I can just go on the node website and download it from there I guess.

NunoCPNP commented 4 years ago

working as expected with node version 12.12.0

sabin2000pro commented 4 years ago

working as expected with node version 12.12.0

So docker run -it -p 3000:3000 should work to run React on localhost 3000 with Node version 12.12.0?

silva2626 commented 4 years ago

I had the same problem.

I uninstalled the current node and installed version 12.12.0

Follow the link: https://nodejs.org/dist/v12.12.0/

Raahul5 commented 4 years ago

hi im Raahul, i tried to create React app using npx, suddenly facing this error can anyone pls help me to solve this, internal/modules/cjs/loader.js:616 if (e.code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED') throw e; ^

Error [ERR_INVALID_PACKAGE_TARGET]: Invalid "exports" main target "index.js" defined in the package config /C:/Users/v-sotb/node_modules/is-promise\package.json at resolveExportsTarget (internal/modules/cjs/loader.js:574:13) at resolveExportsTarget (internal/modules/cjs/loader.js:613:20) at applyExports (internal/modules/cjs/loader.js:503:14) at resolveExports (internal/modules/cjs/loader.js:541:12) at Function.Module._findPath (internal/modules/cjs/loader.js:661:22) at Function.Module._resolveFilename (internal/modules/cjs/loader.js:963:27) at Function.Module._load (internal/modules/cjs/loader.js:859:27) at Module.require (internal/modules/cjs/loader.js:1036:19) at require (internal/modules/cjs/helpers.js:72:18) at Object. (C:\Users\v-sotb\node_modules\run-async\index.js:3:17) { code: 'ERR_INVALID_PACKAGE_TARGET' }

sabin2000pro commented 4 years ago

sabin@Sabins-MacBook-Pro frontend % docker run -p 3000:3000 4cf7ec1d68cc

Can anyone help me out here? I am using node version 12.12.0 and still getting this error?

frontend@0.1.0 start /app react-scripts start

internal/modules/cjs/loader.js:584 if (e.code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED') throw e; ^

Error [ERR_INVALID_PACKAGE_TARGET]: Invalid "exports" main target "index.js" defined in the package config /app/node_modules/is-promise/package.json at resolveExportsTarget (internal/modules/cjs/loader.js:542:13) at resolveExportsTarget (internal/modules/cjs/loader.js:581:20) at applyExports (internal/modules/cjs/loader.js:455:14) at resolveExports (internal/modules/cjs/loader.js:508:23) at Function.Module._findPath (internal/modules/cjs/loader.js:632:31) at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1001:27) at Function.Module._load (internal/modules/cjs/loader.js:884:27) at Module.require (internal/modules/cjs/loader.js:1074:19) at require (internal/modules/cjs/helpers.js:72:18) at Object. (/app/node_modules/run-async/index.js:3:17) { code: 'ERR_INVALID_PACKAGE_TARGET' } npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! frontend@0.1.0 start: react-scripts start npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the frontend@0.1.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2020-04-25T17_15_39_404Z-debug.log sabin@Sabins-MacBook-Pro frontend % .

sabin2000pro commented 4 years ago

hi im Raahul, i tried to create React app using npx, suddenly facing this error can anyone pls help me to solve this, internal/modules/cjs/loader.js:616 if (e.code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED') throw e; ^

Error [ERR_INVALID_PACKAGE_TARGET]: Invalid "exports" main target "index.js" defined in the package config /C:/Users/v-sotb/node_modules/is-promise\package.json at resolveExportsTarget (internal/modules/cjs/loader.js:574:13) at resolveExportsTarget (internal/modules/cjs/loader.js:613:20) at applyExports (internal/modules/cjs/loader.js:503:14) at resolveExports (internal/modules/cjs/loader.js:541:12) at Function.Module._findPath (internal/modules/cjs/loader.js:661:22) at Function.Module._resolveFilename (internal/modules/cjs/loader.js:963:27) at Function.Module._load (internal/modules/cjs/loader.js:859:27) at Module.require (internal/modules/cjs/loader.js:1036:19) at require (internal/modules/cjs/helpers.js:72:18) at Object. (C:\Users\v-sotb\node_modules\run-async\index.js:3:17) { code: 'ERR_INVALID_PACKAGE_TARGET' }

I think some NodeJS dependencies got messed up and for some reason, we are getting this error..

Raahul5 commented 4 years ago

hi im Raahul, i tried to create React app using npx, suddenly facing this error can anyone pls help me to solve this, internal/modules/cjs/loader.js:616 if (e.code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED') throw e; ^ Error [ERR_INVALID_PACKAGE_TARGET]: Invalid "exports" main target "index.js" defined in the package config /C:/Users/v-sotb/node_modules/is-promise\package.json at resolveExportsTarget (internal/modules/cjs/loader.js:574:13) at resolveExportsTarget (internal/modules/cjs/loader.js:613:20) at applyExports (internal/modules/cjs/loader.js:503:14) at resolveExports (internal/modules/cjs/loader.js:541:12) at Function.Module._findPath (internal/modules/cjs/loader.js:661:22) at Function.Module._resolveFilename (internal/modules/cjs/loader.js:963:27) at Function.Module._load (internal/modules/cjs/loader.js:859:27) at Module.require (internal/modules/cjs/loader.js:1036:19) at require (internal/modules/cjs/helpers.js:72:18) at Object. (C:\Users\v-sotb\node_modules\run-async\index.js:3:17) { code: 'ERR_INVALID_PACKAGE_TARGET' }

I think some NodeJS dependencies got messed up and for some reason, we are getting this error..

yeah i think so....never face this error before :(

YukaLangbuana commented 4 years ago

@sabinlungudotcpp @Raahul5 Currently a Node dependency broke (https://github.com/then/is-promise/pull/15) and they're working on it. For now, the idea is to somehow downgrade that dependency to the last working version. You can try downgrade the problematic dependency by itself to v2.1.0 as mentioned here: https://github.com/then/is-promise/issues/14#issuecomment-619400516

$ npm install is-promise@2.1.0

If that doesn't work, downgrade the whole thing (Node) to its last working version. Node v12.12.0 and its included dependencies works for me.

$ n 12.12.0 $ npx create-react-app react-sample

Edited for clarity.

sabin2000pro commented 4 years ago

I downgraded Node to 12.12.0 and everything works fine, so Node has been screwed up recently

Doesn't work for me.

sabin2000pro commented 4 years ago

@sabinlungudotcpp @Raahul5 Currently a Node dependency broke (then/is-promise#15) and they're working on it. For now, the idea is to somehow downgrade that dependency to the last working version. Node 12.12.0 works for me.

$ n 12.12.0 $ npx create-react-app react-sample

if that doesn't work, you can try downgrade the problematic dependency to 2.1.0 as mentioned here: then/is-promise#14 (comment)

$ npm install is-promise@2.1.0

Still doesn't work. I still get the error I posted above.

vic2tee4u commented 4 years ago

Install NVM using this link then use that to install version 12.12.0. It worked for me. The instruction is clear

wzhang66 commented 4 years ago

Same here

Raahul5 commented 4 years ago

@sabinlungudotcpp @Raahul5 Currently a Node dependency broke (then/is-promise#15) and they're working on it. For now, the idea is to somehow downgrade that dependency to the last working version. Node 12.12.0 and its included dependencies works for me.

$ n 12.12.0 $ npx create-react-app react-sample

if that doesn't work, you can try downgrade the problematic dependency by itself to 2.1.0 as mentioned here: then/is-promise#14 (comment)

$ npm install is-promise@2.1.0

still not work can't create app

MarkKragerup commented 4 years ago

If you are on NPM, run: npm install is-promise@2.1.0 --save --save-exact

rahuld109 commented 4 years ago

npm uninstall create-react-app npm uninstall -g create-react-app npm install -g create-react-app@1.5.2 create-react-app --help //to check if installed correctly, should return the help info create-react-app confusion --scripts-version=react-scripts@1.1.4 cd confusion npm start

This creates the app but unable to do yarn start or npm start

jakejarvis commented 4 years ago

This should be fixed now that https://github.com/then/is-promise/pull/15 is merged. :)

brentvatne commented 4 years ago

the author of is-promise has resolved the issue: https://github.com/then/is-promise/issues/14#issuecomment-619417917

it should work if you reinstall create-react-app if you have a global install, or use npx create-react-app

(this same issue impacted expo-cli and i confirmed it there too)

AngryR4v3n commented 4 years ago

It is also happening while trying to start an app, downgrading Node to 12.12.0 solved the issue.

rahuld109 commented 4 years ago

npm uninstall create-react-app npm uninstall -g create-react-app npm install -g create-react-app@1.5.2 create-react-app --help //to check if installed correctly, should return the help info create-react-app confusion --scripts-version=react-scripts@1.1.4 cd confusion npm start

This creates the app but unable to do yarn start or npm start

For Npm start and yarn start install npm install is-promise@2.2.2 --save --save-exact

This resolved the issue for me I'm on Node v14 latest one // resolved the must use import to load Es module //

Fixed for me

Raahul5 commented 4 years ago

If you are on NPM, run: npm install is-promise@2.1.0 --save --save-exact

thanx #mark its work own app created :)

imarchit19 commented 4 years ago

npm uninstall create-react-app npm uninstall -g create-react-app npm install -g create-react-app@1.5.2 create-react-app --help //to check if installed correctly, should return the help info create-react-app confusion --scripts-version=react-scripts@1.1.4 cd confusion npm start

This creates the app but unable to do yarn start or npm start

For Npm start and yarn start install npm install is-promise@2.1.0 --save --save-exact

This resolved the issue for me I'm on Node v14 latest one // resolved the must use import to load Es module //

Fixed for me

Thanks Man This worked for me.

Steen3S commented 4 years ago

They fixed the issue, npx create-react-app should be working normal again.

elveskevtar commented 4 years ago

I was trying it for the last two hours on Mac instead of my windows machine. I thought that was the issue. Turns out it was just a problem with npm for the last few hours 🤦 ...

shiv41297 commented 4 years ago

@DEATRYDE thx bro, your way worked for me too. Great Work

chrisweb commented 4 years ago

It’s fixed see https://github.com/then/is-promise/issues/20

malvesbertoni commented 4 years ago

if you just want to create react app, you can do this while waiting for a fix: step 1: yarn init -y step 2: Insert this to package.json

"resolutions": {
    "is-promise": "2.1.0",
    "run-async/is-promise": "2.1.0"
  }

step 3: yarn add --dev create-react-app step 4: node node_modules/create-react-app/createReactApp.js ../my-app

this one worked for me

worked for me as well

badmus306 commented 4 years ago

I am having this issue as well

joeln18 commented 4 years ago

Gracias, me funciono también con node v12.16. Solo que instale npm install is-promise@2.2.2 --save --save-exact

Daniel15 commented 4 years ago

This should be resolved now. As @brentvatne mentioned above, if you have create-react-app installed globally, uninstalling then reinstalling should fix it. Otherwise, npx create-react-app or yarn dlx create-react-app always uses the latest version.