0

I face a problem while starting the server...

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\WINDOWS\system32> cd C:\Users\Smart-User^
PS C:\Users\Smart-User^> cd C:\Users\Smart-User^\Desktop\2q9\react\react-app
PS C:\Users\Smart-User^\Desktop\2q9\react\react-app> npm start

> [email protected] start C:\Users\Smart-User^\Desktop\2q9\react\react-app
> react-scripts start

internal/modules/cjs/loader.js:969
  throw err;
  ^

Error: Cannot find module 'C:\Users\Smart-User\Desktop\2q9\react\react-app\node_modules\react-scripts\bin\react-scripts.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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!     C:\Users\Smart-User^\AppData\Roaming\npm-cache\_logs\2020-11-15T15_33_30_740Z-debug.log

Usually I can't understand errors in the powershell but now I think because of this:

Error: Cannot find module 'C:\Users\Smart-User\Desktop\2q9\react\react-app\node_modules\react-scripts\bin\react-scripts.js'

the ^ sign in the username is not there named in the directory, I don't know why I typed it before, I was young, and now I tried lots of methods to change the username but none of them worked... Do I have to make a new and different User Name? The problem Here is I have many important files, or if there another way please help me, or I can't understand the problem and it is different from I think, help me again, Thanks in advance

2 Answers 2

1

npm cannot handle paths with some special characters like ^ and will simply ignore them and try the path without it there.

Usually I'd say "rename the folder and don't use special characters", but since this is a user profile renaming is a bit messy. Fortunately there's an easy workaround.

Create a symbolic link like this (needs to be run in an elevated command prompt):

mklink /D "C:\Users\Smart-User" "C:\Users\Smart-User^"

Now C:\Users\Smart-User redirects to C:\Users\Smart-User^ and npm will run without issue.

Sign up to request clarification or add additional context in comments.

2 Comments

should I run it immediately or what? I tried that but it says Access is denied
Like I said, you need to run it in an elevated command prompt. Click on your start menu, type "cmd" (without quotes) then rightclick on the result and select "Run as Administrator". Run the command above in that window. Only needs to be done once.
0

You have to install your packages first.

npm install
npm start

2 Comments

That's not the issue here, even if everything is set up correctly npm will fail if there's a ^ in the path. You can recreate the issue easily by taking a working npm setup and just renaming on of the directories above and adding a ^ and you will get the same error. Renaming it to whatever you want but without special characters will work, with eg. ^ it won't. This is on Windows btw, not sure if the same issue exists on Linux.
Ah ok, yes since I am on Linux I couldn't properly recreate the issue. I read MODULE_NOT_FOUND and by experience 99% of the time it's a missing package in the node_modules that can be fixed with an npm install

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.