简体   繁体   English

ReactJS | 设置开发环境

[英]ReactJS | Setting up Development Environment

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

> react-app@0.1.0 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! react-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-app@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!     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:通常我无法理解 powershell 中的错误,但现在我认为是因为这个:

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问题这是我有很多重要文件,或者如果有其他方法请帮助我,或者我无法理解问题并且与我想的不同,再次帮助我,提前致谢

npm cannot handle paths with some special characters like ^ and will simply ignore them and try the path without it there. npm 无法处理带有 ^ 等特殊字符的路径,只会忽略它们并尝试没有它的路径。

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.现在 C:\Users\Smart-User 重定向到 C:\Users\Smart-User^ 并且 npm 将正常运行。

You have to install your packages first.你必须先安装你的包。

npm install
npm start

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM