Skip to content

create-react-app fails due to node_modules being created in a wrong directory on Windows #3326

Closed

Description

@LeonelAV

Is this a bug report?

yes

Can you also reproduce the problem with npm 4.x?

(Write your answer here.)

Which terms did you search for in User Guide?

(Write your answer here if relevant.)

Environment

  1. node -v: 6.10.2
  2. npm -v:4.6.1
  3. yarn --version (if you use Yarn):
  4. npm ls react-scripts (if you haven’t ejected):

Then, specify:

  1. Operating system: windows 10
  2. Browser and version (if relevant):

Steps to Reproduce

(Write your steps here:)

  1. npm install -g create-react-app
  2. create react app name-of-my-project
  3. starts to install react, react-dom and react-scripts and before finish i get an error: Aborting Instalation

Aborting installation.
Unexpected error. Please report it as a bug:
{ Error: Cannot find module 'C:\Users\leonel\Desktop\pseudogram\node_modules\react-
scripts\package.json'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at checkNodeVersion (C:\Users\leonel\AppData\Roaming\npm\node_modules\create-re
act-app\createReactApp.js:476:23)
at getPackageName.then.then.then.packageName (C:\Users\leonel\AppData\Roaming\n
pm\node_modules\create-react-app\createReactApp.js:283:7)
at process._tickCallback (internal/process/next_tick.js:109:7) code: 'MODULE_NO
T_FOUND' }

Deleting generated file... package.json
Deleting pseudogram / from C:\Users\leonel\Desktop
Done.

Expected Behavior

I expect it create the folder project

Actual Behavior

Aborting installation.
Unexpected error. Please report it as a bug:
{ Error: Cannot find module 'C:\Users\leonel\Desktop\pseudogram\node_modules\react-
scripts\package.json'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at checkNodeVersion (C:\Users\leonel\AppData\Roaming\npm\node_modules\create-re
act-app\createReactApp.js:476:23)
at getPackageName.then.then.then.packageName (C:\Users\leonel\AppData\Roaming\n
pm\node_modules\create-react-app\createReactApp.js:283:7)
at process._tickCallback (internal/process/next_tick.js:109:7) code: 'MODULE_NO
T_FOUND' }

Deleting generated file... package.json
Deleting pseudogram / from C:\Users\leonel\Desktop
Done.

Activity

  1. Timer commented on Oct 25, 2017

    @Timer
    Contributor

    Try to clear your npm cache.

  2. LeonelAV commented on Oct 25, 2017

    @LeonelAV
    Author

    I already did that and still does not work

  3. gaearon commented on Oct 25, 2017

    @gaearon
    Contributor

    Can you try with some other npm version? e.g. maybe npm 5

  4. LeonelAV commented on Oct 25, 2017

    @LeonelAV
    Author

    @gaearon i tried with other versions of npm(included npm 5) and node and still got the same problem.

  5. LeonelAV commented on Oct 25, 2017

    @LeonelAV
    Author

    i tried again with new versions of npm and nothing. Still same problem

  6. LeonelAV commented on Oct 26, 2017

    @LeonelAV
    Author

    I realize that the node_modules folder is created in another folder and not in the folder of the project, thats why it can´t found the module i guess... how can i solve this? @Timer @gaearon

  7. davidr9 commented on Oct 26, 2017

    @davidr9

    I am experiencing the exact same issue. I also noticed the node_modules folder is created outside the project in question, directly in my C drive.

    npm version: 3.10.10
    node version: 6.9.5

    OS: Windows 7

    My friend attempted to replicate the issue using the exact same steps on a Mac, but the app was created as expected for him.

  8. Timer commented on Oct 27, 2017

    @Timer
    Contributor

    Unfortunately, we're ill-equipped to provide support for bugs like these.

    Make sure you actually cleared the npm cache by using --force on npm >=5.
    If that doesn't help, you'll need to open an issue with npm -- this is a bug with their package manager.

    I'm sorry we can't provide more assistance.

    I realize that the node_modules folder is created in another folder and not in the folder of the project

    I'm not sure what you mean by this?

  9. LeonelAV commented on Oct 27, 2017

    @LeonelAV
    Author

    I'm not sure what you mean by this?

    i am doing create-react-app command in Desktop folder : C:\Users\leonel\Desktop: create-react-app my-app
    and the nodules_modules folder is not created in my-app folder, instead is created in antoher folder that i have, called Projects.

  10. LeonelAV commented on Oct 27, 2017

    @LeonelAV
    Author

    I also cleared npm cache on npm 5.5.0 and still same issue.

  11. rostun commented on Oct 27, 2017

    @rostun

    I'm getting the same error as op (on windows 10, npm 5.5.1, and tried force clearing npm cache) :

    wat2

    While investigating, i also noticed that node_modules folder is "missing" because its being created at C:\node_modules and not " C:\test\my-app\node_modules as you can see below:

    wat

    I tried this about a month ago (on windows 10) and it worked

  12. LeonelAV commented on Oct 27, 2017

    @LeonelAV
    Author

    So @rostun cleaned cache in npm 5.5.1solved the problem for you? I didn't understand how do you solved this? Thanks

  13. gaearon commented on Oct 27, 2017

    @gaearon
    Contributor

    Since the issue is very recent and symptoms are similar, there has to be something that updated recently causing this.

    Is there anything in common between your systems?

  14. rostun commented on Oct 27, 2017

    @rostun

    @gaearon with what @davidr9 mentioned, maybe its a windows only issue

    since node_modules isn't being copied into the right path, maybe something changed with the way the path for that is determined

  15. gaearon commented on Oct 27, 2017

    @gaearon
    Contributor

    We've been testing Windows in the past releases, and 2 days ago was the first time anyone brought it up. We haven't made a release in that timeframe. This is why I think it's some other update that's causing the issue.

    If Windows support was broken for everyone we'd have known it a long time ago.

  16. 26 remaining items

  17. LeonelAV commented on Oct 30, 2017

    @LeonelAV
    Author

    @gaearon is working now.

    Should i keep this changes???
    In other words please add root as an argument to this call, this function definition, and then change this line to be:

    const child = spawn(command, args, { stdio: 'inherit', cwd: root })

    Thanks a lot

  18. gaearon commented on Oct 30, 2017

    @gaearon
    Contributor

    No, you can remove them. We'll try to figure out a better way to surface the cause of the problem though.

  19. LeonelAV commented on Oct 30, 2017

    @LeonelAV
    Author

    Ok..Thank you

  20. Timer commented on Oct 30, 2017

    @Timer
    Contributor

    @gaearon you just got way too familiar with Windows internals 😆

  21. gaearon commented on Oct 30, 2017

    @gaearon
    Contributor

    More than I care to know.

  22. gaearon commented on Oct 30, 2017

    @gaearon
    Contributor
  23. gaearon commented on Oct 30, 2017

    @gaearon
    Contributor

    I added a better warning for this in #3355.

    If you bump into this, the solution is described here: #3326 (comment)

  24. gaearon commented on Oct 30, 2017

    @gaearon
    Contributor

    create-react-app@1.4.2 should now emit a readable error in this case.

  25. ManojKSingh commented on Apr 19, 2018

    @ManojKSingh

    I was facing the same issue,

    npm cache clean --force

    worked form me

  26. chadsteele commented on Jul 29, 2018

    @chadsteele

    My admin made my default Windows username "first lastname" and so, the c:\Users\first lastname\AppData... has a space in the path and causes headaches with npm, etc. I tried creating a new user with just my first name (no spaces) and everything installs fine.

  27. sudipt1999 commented on Sep 6, 2018

    @sudipt1999

    Hey! I was just having the same issue as above node modules not found while i was using git bash terminal than i switched to nodejs terminal and surprisingly it work no more showing node_modules not found !!!
    So i would suggest to try this way around for a while until they find solution!!!1

  28. tgifgirltechlaunch commented on Oct 10, 2018

    @tgifgirltechlaunch

    This worked for me https://github.com/facebook/create-react-app/issues/138
    Run.
    $ npm config set prefix /usr/local
    And then reinstall react.
    $ npm install -g create-react-app
    The command should work now.
    $ create-react-app my-app

  29. Arshaq1996 commented on Jan 3, 2019

    @Arshaq1996

    F:\React-Lectures\Contact manger>npm install -g create-react-app
    'npm' is not recognized as an internal or external command,
    operable program or batch file.

    when i use this command on general cmd it is workin but when i came to folder after install npm globally write the command create-react-app my-app this error is occured 'npm' is not recognized as an internal or external command,
    operable program or batch file.

  30. locked and limited conversation to collaborators on Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions