简体   繁体   English

第一个带有 create-react-app 的应用程序,npm 开始不起作用

[英]First app with create-react-app, npm start not working

I am trying create my first react app and running into issues basically at step 1. I am trying npm start on the default create-react-app install and I am getting the follow error.我正在尝试创建我的第一个 React 应用程序并基本上在步骤 1 中遇到问题。我正在尝试在默认的 create-react-app 安装上使用 npm start 并且出现以下错误。 I have included screenshots showing create-react-app ran successfully but that has not fixed anything.我已经包含了显示 create-react-app 成功运行的屏幕截图,但这并没有解决任何问题。 I have included screenshots of it successfully running create-react-app and of me running npm start with no luck.我已经包含了它成功运行 create-react-app 和我运行 npm start 但没有运气的截图。 Thanks.谢谢。

Here is the log file:这是日志文件:

18 verbose npm v6.4.1 19 error file sh 20 error code ELIFECYCLE 21 error errno ENOENT 22 error syscall spawn 23 error robofriends@0.1.0 start: react-scripts start 23 error spawn ENOENT 24 error Failed at the robofriends@0.1.0 start script. 18 详细 npm v6.4.1 19 错误文件 sh 20 错误代码 ELIFECYCLE 21 错误 errno ENOENT 22 错误系统调用 spawn 23 错误 robofriends@0.1.0 start: react-scripts start 23 错误 spawn ENOENT 24 错误在 robofriends@0.0. 失败脚本。 24 error This is probably not a problem with npm. 24 错误 这可能不是 npm 的问题。 There is likely additional logging output above.上面可能有额外的日志输出。 25 verbose exit [ 1, true ] 25 详细退出 [ 1, true ]

I tried this solution and it did not work for me:我尝试了这个解决方案,但它对我不起作用:

stackoverflow.com/a/42539669/5069226 stackoverflow.com/a/42539669/5069226

create-react-app running创建反应应用程序运行

npm start failing npm 开始失败

Looks like this has to do with your workspace path.看起来这与您的工作区路径有关。

I tried to replicate this on my machine with the path /tmp/Users/Neil/Desktop/Complete Web Developer/Section 18_React:Redux/robofriends , and i was able to reproduce your error.我尝试使用路径/tmp/Users/Neil/Desktop/Complete Web Developer/Section 18_React:Redux/robofriends在我的机器上复制它,并且我能够重现您的错误。

╭─  /tmp/Users/Neil/Desktop/Complete Web Developer/Section 
18_React:Redux/robofriends 
╰ yarn start                                                                                                                                                                                                     K8S: tools    11:37:33
yarn run v1.7.0
$ react-scripts start
/bin/sh: react-scripts: command not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

But when i moved the robofriends directory up higher in the tree, it worked fine.但是当我将robofriends目录移到树中更高的位置时,它运行良好。

╭─  /tmp/Users/robofriends 
╰ yarn start                                                                                                                                                                                             K8S: tools  INT(-2) ↵  11:38:34
yarn run v1.7.0
Starting the development server...

I guessed it could be either the long path to node modules or the non-alphanum characters you have in your path, : , _ .我猜它可能是节点模块的长路径或路径中的非字母字符, :_ So i went back down to the React:Redux directory and renamed it to ...React_Redux and tried npm start again in /tmp/Users/Neil/Desktop/Complete Web Developer/Section 18_React_Redux/robofriends`, and it worked just fine :)所以我回到React:Redux目录并将其重命名为...React_Redux并在 /tmp/Users/Neil/Desktop/Complete Web Developer/Section 18_React_Redux/robofriends` 中再次尝试npm start ,它工作得很好: )

So looks like npm doesn't like the : in the executable path.所以看起来npm不喜欢:在可执行路径中。

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

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