Closed LeonelAV closed 6 years ago
Try to clear your npm cache.
I already did that and still does not work
Can you try with some other npm version? e.g. maybe npm 5
@gaearon i tried with other versions of npm(included npm 5) and node and still got the same problem.
i tried again with new versions of npm and nothing. Still same problem
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
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.
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?
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.
I also cleared npm cache on npm 5.5.0 and still same issue.
I'm getting the same error as op (on windows 10, npm 5.5.1, and tried force clearing npm cache) :
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:
I tried this about a month ago (on windows 10) and it worked
So @rostun cleaned cache in npm 5.5.1solved the problem for you? I didn't understand how do you solved this? Thanks
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?
@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
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.
well still doesn't work!! i tried with diferent versions of npm, cleaned cache and opened an issue in npm to try to solve the problem but i am not getting any answer.
@rostun did you solved the problem??
Can you link to the npm issue you filed so we can track it?
https://github.com/npm/npm/issues/18981
this is link of npm issue.
OK, this might be our bug but I don’t know where it is. I’ll need some help from somebody who can experience it.
If you run
create-react-app myapp
and then kill the process (e.g. with Ctrl+C) while it's running npm, can you describe the directory structure?
Does myapp/package.json
get created?
Or does package.json
get created in a wrong directory (e.g. c:\
)?
The key evidence that something is wrong is here:
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.
and
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:
For two different people, node_modules
is created in a different folder but it's not even always a parent folder. It sounds more like these are "initial" folders for the shell (C:\
and C:\Projects
sound like something one would configure as default working directory), and for some reason npm install
respects them. The question is whether package.json
is in the wrong place (and then it's out fault) or if it's in the right place but npm is creating node_modules
in the wrong place (and then it's an npm bug).
It is also possible that we create package.json
in the right place but then spawn npm in the wrong place. This log supports that theory:
Deleting generated file... package.json
When i do create-react-app
and then i kill the process the folder my-app is created in the right place, and the package.json
is also created inside the my-app folder
So the package.json
is created in the right place, only the node_modules
folder is created outside the my-app folder
Hmm, we don't set cwd
but shouldn't need to: https://github.com/facebookincubator/create-react-app/blob/345f5508610a96e720b91785b49c7a934bbc477b/packages/create-react-app/createReactApp.js#L235
We change the working directory to the project folder here: https://github.com/facebookincubator/create-react-app/blob/345f5508610a96e720b91785b49c7a934bbc477b/packages/create-react-app/createReactApp.js#L162
@LeonelAV can you try editing your global CLI and explicitly setting cwd
for the spawn?
Maybe some of cross-spawn
dependencies updated and broke things.
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 })
@LeonelAV no unfortunately I wasn't able to figure it out :/ in the interest of time i had a buddy of mine create the repo for me and am just working off of that right now (create-react-app worked on his machine)
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 })
I tried this but i'm still getting the same Error. Should i change something else or just this three lines?
Anything unusual about shell? Are you using Cmd, PowerShell, GitBash, Cygwin, etc?
I'm using Cmd.
Can you keep the existing changes you made and also try putting
process.chdir(root);
before the spawn
call?
@LeonelAV Is there any special significance to the Projects
folder on your computer? Is it the default directory you end up with when opening the shell? Is it the value of some ENV variable?
What is the output of
reg query "HKCU\Software\Microsoft\Command Processor" /v AutoRun
on your machine?
Is:
HKEY_CURRENT_USER\Software\Microsoft\Command Processor AutoRun REG_EXPAND_SZ CD/d C:\Users\leonel\Desktop\Projects
Do you remember setting this key? 😛
I thought Projects
looked suspicious (it is not special for the OS, and is not a parent directory of your projects judging by the log) so I thought maybe you tried to make your shell always start in this directory, and followed a bad tutorial that messed up your system.
I googled "how to change default terminal directory on windows" which led me to this answer with a scary "it can also really mess things up" disclaimer about the other answer.
That link led me to this blog entry describing the problem: https://blogs.msdn.microsoft.com/oldnewthing/20071121-00/?p=24433/ (it's a good blog in general btw).
Please run:
reg delete "HKLM\Software\Microsoft\Command Processor" /v AutoRun /f
reg delete "HKCU\Software\Microsoft\Command Processor" /v AutoRun /f
and then try creating an app again.
It gives me:
ERROR: The system was unable to find the specified registry key or value.
Try again, I edited the comment (my syntax was wrong).
@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
No, you can remove them. We'll try to figure out a better way to surface the cause of the problem though.
Ok..Thank you
@gaearon you just got way too familiar with Windows internals 😆
More than I care to know.
I added a better warning for this in https://github.com/facebookincubator/create-react-app/pull/3355.
If you bump into this, the solution is described here: https://github.com/facebookincubator/create-react-app/issues/3326#issuecomment-340501321
create-react-app@1.4.2
should now emit a readable error in this case.
I was facing the same issue,
npm cache clean --force
worked form me
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.
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
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
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
node -v
: 6.10.2npm -v
:4.6.1yarn --version
(if you use Yarn):npm ls react-scripts
(if you haven’t ejected):Then, specify:
Steps to Reproduce
(Write your steps here:)
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.