facebook / create-react-app

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

Unexpected error upon creating a new Project #4321

Closed ghost closed 6 years ago

ghost commented 6 years ago

Is this a bug report?

Yes

Did you try recovering your dependencies?

No, everything is up-to-date, and it is a NEW project.

Which terms did you search for in User Guide?

None, since it is a "start" of a project.

Environment

  1. node -v: v8.9.4
  2. npm -v: 5.6.0
  3. yarn --version (if you use Yarn): 1.6.0
  4. npm ls react-scripts (if you haven’t ejected): `-- (empty)

Then, specify:

  1. Operating system: Windows 10
  2. Browser and version (if relevant): N/R

Steps to Reproduce

(Write your steps here:)

  1. Install Node/NPM
  2. Install create-react-app (npm install -g create-react-app)
  3. Create a new Project (create-react-app dashboard)

Expected Behavior

Create a new Folder with the project inside.

Actual Behavior

source $ create-react-app dashboard

Creating a new React app in ~\Projects\test\source\dashboard.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

yarn add v1.6.0
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[###########################################################################################################################################################] 1113/1114 Aborting installation.
Unexpected error. Please report it as a bug:
{ Error: Cannot find module '~\Projects\test\source\dashboard\node_modules\react-scripts\package.json'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at checkNodeVersion (~\scoop\persist\nodejs\bin\node_modules\create-react-app\createReactApp.js:514:23)
    at getPackageName.then.then.then.packageName (~\scoop\persist\nodejs\bin\node_modules\create-react-app\createReactApp.js:312:7)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7) code: 'MODULE_NOT_FOUND' }

Deleting generated file... package.json
Deleting dashboard / from ~\Projects\test\source
Done.
source $

Reproducible Demo

Since there is no way to create the Project, it is not possible to build a "demo".

Thanks in advance, and keep up the amazing work!

Timer commented 6 years ago

Are you using the standard npm registry?

ghost commented 6 years ago

@Timer yes, it just "started" happening today, as I upgraded to the latest version of CRA.

source $ create-react-app --version
1.5.2

Thanks.

Timer commented 6 years ago

Odd, can you try using npx instead like in our README?

gaearon commented 6 years ago

I wonder if any transitive updates released new versions recently. Maybe something upstream related to waiting for a process to finish broke.

ghost commented 6 years ago

@Timer Using npx produced the same result:

~ $ npx --version
npx: installed 1 in 1.784s
Path must be a string. Received undefined
9.7.1
source $ npx create-react-app dashboard                                                                                                                                
npx: installed 1 in 1.764s                                                                                                                                             
Path must be a string. Received undefined                                                                                                                              
~\scoop\apps\nodejs\current\bin\node_modules\create-react-app\index.js                                                                                    

Creating a new React app in ~\Projects\test\source\dashboard.                                                                                             

Installing packages. This might take a couple of minutes.                                                                                                              
Installing react, react-dom, and react-scripts...                                                                                                                      

yarn add v1.6.0                                                                                                                                                        
info No lockfile found.                                                                                                                                                
[1/4] Resolving packages...                                                                                                                                            
[2/4] Fetching packages...                                                                                                                                             
[##########################################################################################################################################################] 1113/1114 
Aborting installation.                                                                                                                                                 
Unexpected error. Please report it as a bug:                                                                                                                           
{ Error: Cannot find module '~\Projects\test\source\dashboard\node_modules\react-scripts\package.json'                                                    
    at Function.Module._resolveFilename (module.js:538:15)                                                                                                             
    at Function.Module._load (module.js:468:25)                                                                                                                        
    at Module.require (module.js:587:17)                                                                                                                               
    at require (internal/module.js:11:18)                                                                                                                              
    at checkNodeVersion (~\scoop\persist\nodejs\bin\node_modules\create-react-app\createReactApp.js:514:23)                                               
    at getPackageName.then.then.then.packageName (~\scoop\persist\nodejs\bin\node_modules\create-react-app\createReactApp.js:312:7)                       
    at <anonymous>                                                                                                                                                     
    at process._tickCallback (internal/process/next_tick.js:188:7) code: 'MODULE_NOT_FOUND' }                                                                          

Deleting generated file... package.json                                                                                                                                
Deleting dashboard / from ~\Projects\test\source                                                                                                          
Done.
ghost commented 6 years ago

@gaearon Anything I could do to help on this thought?

gaearon commented 6 years ago

Can't reproduce on macOS on these versions.

Is there anything special about your Windows environment? Why do paths start with ~?

ghost commented 6 years ago

@gaearon Nothing special, the only thing "different" is that everything is installed with Scoop. The "~" were to just omit the home folder. and it is "C:\Users\julio".

About 2 days ago, with this very same environment, I created a Project, with no errors.

gaearon commented 6 years ago

I see. Maybe worth trying to test with Scoop specifically. I can give it a try to reproduce some time later this or next week.

If you run with --use-npm, does the problem persist?

ghost commented 6 years ago

@gaearon Running with --use-npm succeeded.

Maybe it is an issue with yarn (installed with Scoop). I'll try and install it from npm, and get back to you ASAP.

source $ create-react-app dashboard --use-npm

Creating a new React app in ~\Projects\test\source\dashboard.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

> uglifyjs-webpack-plugin@0.4.6 postinstall ~\Projects\test\source\dashboard\node_modules\uglifyjs-webpack-plugin
> node lib/post_install.js

+ react-scripts@1.1.4
+ react-dom@16.3.2
+ react@16.3.2
added 1317 packages in 301.936s

Success! Created dashboard at ~\Projects\test\source\dashboard
Inside that directory, you can run several commands:

  npm start
    Starts the development server.

  npm run build
    Bundles the app into static files for production.

  npm test
    Starts the test runner.

  npm run eject
    Removes this tool and copies build dependencies, configuration files
    and scripts into the app directory. If you do this, you can’t go back!

We suggest that you begin by typing:

  cd dashboard
  npm start

Happy hacking!
ghost commented 6 years ago

Removed yarn from Scoop.

source $ scoop uninstall yarn
Uninstalling 'yarn' (1.6.0).
Unlinking ~\scoop\apps\yarn\current
Removing ~\scoop\apps\yarn\current\bin from your path.
Removing ~\scoop\apps\yarn\current\Yarn\bin from your path.
Removing older version (1.3.2).
Removing older version (1.5.1).
'yarn' was uninstalled.

Installed with npm

source $ npm install -g yarn
~\scoop\persist\nodejs\bin\yarn -> ~\scoop\persist\nodejs\bin\node_modules\yarn\bin\yarn.js
~\scoop\persist\nodejs\bin\yarnpkg -> ~\scoop\persist\nodejs\bin\node_modules\yarn\bin\yarn.js
+ yarn@1.6.0
added 1 package in 1.846s

Everything went fine:

source $ create-react-app dashboard-yarn

Creating a new React app in ~\Projects\test\source\dashboard-yarn.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

yarn add v1.6.0
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.1.3: The platform "win32" is incompatible with this module.
info "fsevents@1.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 734 new dependencies.
info Direct dependencies
├─ react-dom@16.3.2
├─ ...
└─ react@16.3.2
info All dependencies
├─ abab@1.0.4
├─ ...
└─ yargs-parser@5.0.0
Done in 269.44s.

Success! Created dashboard-yarn at ~\Projects\test\source\dashboard-yarn
Inside that directory, you can run several commands:

  yarn start
    Starts the development server.

  yarn build
    Bundles the app into static files for production.

  yarn test
    Starts the test runner.

  yarn eject
    Removes this tool and copies build dependencies, configuration files
    and scripts into the app directory. If you do this, you can’t go back!

We suggest that you begin by typing:

  cd dashboard-yarn
  yarn start

Happy hacking!
ghost commented 6 years ago

Returning to yarn from Scoop, brought the error back. I believe there's a difference in the "official" yarn distribution regarding the npm one.

Since I am not an expert, I cannot tell exactly what it is. But I am available to help with anything.

[Edit] Browsing from Google, I stumbled int this old issue (#2751).

[Edit2] Just posted a comment on the Yarn issue tracker, so I think this one could be closed, since it appears NOT to be an issue with react-scripts per se, or even with npm.

pushred commented 6 years ago

I'm running into this error trying out the monorepo support in 2.0 using either npx or yarn create, react-scripts@next or 1.1.4, I consistently encounter this error when trying to create a new app from the root of my workspaces-enabled repo.

If I go to a fresh dir that does not have a package.json with the workspaces property I'm able to run the create script without issue with npx (or yarn create, if not using next). The issue returns if I add that property.

See also: https://github.com/yarnpkg/yarn/issues/4906

node 8.5.1 npm 5.10.0 yarn 1.6.0 os x 10.13.3

anuj0877 commented 6 years ago

2018-05-22T11_12_43_661Z-debug.log I am also facing the issue:

D:\reactJS>npm install create-react-app -g
C:\Users\Anuj Sharma\AppData\Roaming\npm\create-react-app -> C:\Users\Anuj Sharma\AppData\Roaming\npm\node_modules\create-react-app\index.js
+ create-react-app@1.5.2
updated 1 package in 13.987s

D:\reactJS>create-react-app my-app

Creating a new React app in D:\reactJS\my-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

yarn add v1.6.0
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/term-size/-/term-size-1.2.0.tgz: EPERM: operation not permitted, open 'C:\\Users\\Anuj Sharma\\AppData\\Local\\Yarn\\Cache\\v1\
pm-term-size-1.2.0-458b83887f288fc56d6fffbfad262e26638efa69\\vendor\\windows\\term-size.exe'".
info If you think this is a bug, please open a bug report with the information provided in "D:\\reactJS\\my-app\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Aborting installation.
  yarnpkg add --exact react react-dom react-scripts --cwd D:\reactJS\my-app has failed.

Deleting generated file... package.json
Deleting generated file... yarn-error.log
Deleting my-app / from D:\reactJS
Done.
Timer commented 6 years ago

Closing per previous comment. Please file this issue with Yarn or Scoop if they're modifying the default Yarn installation -- thanks!

courtens commented 6 years ago

uninstalling nodejs; deleting folder C:\Program Files\nodejs; and reinstall is what worked for me.

jaisonjjames commented 5 years ago

I see. Maybe worth trying to test with Scoop specifically. I can give it a try to reproduce some time later this or next week.

If you run with --use-npm, does the problem persist?

I had the same issue but create-react-app dashboard --use-npm helped me, is this a real solution for this issue?

ghost commented 5 years ago

I see. Maybe worth trying to test with Scoop specifically. I can give it a try to reproduce some time later this or next week. If you run with --use-npm, does the problem persist?

I had the same issue but create-react-app dashboard --use-npm helped me, is this a real solution for this issue?

@jaisonjjames it is a real solution, but keep in mind you are forcing the tool to use NPM instead of Yarn.

For me, the solutions was "not to use" the official Yarn (from Scoop), and instead use the NPM repo Yarn. (as I said, I'm not able to understand what could be different, I don't have the knowledge to)