【问题标题】:First app with create-react-app, npm start not working第一个带有 create-react-app 的应用,npm start 不工作
【发布时间】:2019-02-18 12:39:12
【问题描述】:

我正在尝试创建我的第一个 react 应用程序并基本上在第 1 步遇到问题。我正在尝试 npm start 在默认的 create-react-app 安装上,但我收到了以下错误。我已经包含了显示 create-react-app 成功运行的屏幕截图,但这并没有解决任何问题。我已经包含了它成功运行 create-react-app 和我运行 npm start 但没有运气的屏幕截图。谢谢。

这是日志文件:

18 详细 npm v6.4.1 19 错误文件 sh 20 错误代码 ELIFECYCLE 21 错误 errno ENOENT 22 错误系统调用产生 23 错误 robofriends@0.1.0 开始:react-scripts start 23 错误生成 ENOENT 24 错误在 robofriends@0.1.0 启动脚本中失败。 24 错误 这可能不是 npm 的问题。上面可能有额外的日志输出。 25 详细退出 [1, true]

我尝试了这个解决方案,但它对我不起作用:

stackoverflow.com/a/42539669/5069226

create-react-app running

npm start failing

【问题讨论】:

  • 我试过了,不幸的是它没有解决我的问题:(
  • 在执行npm install 之前是否删除了package-lock.json
  • 我没有..我应该有吗?
  • 您能否运行tail -n 1000 /Users/Neil/.npm/_logs/<that long filename from the error screenshot>.log 并将其添加到帖子中。请从控制台复制和粘贴,因为它更易于我们使用。

标签: reactjs create-react-app npm-start


【解决方案1】:

看起来这与您的工作区路径有关。

我尝试在我的机器上使用路径 /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.

但是当我将robofriends 目录在树中向上移动时,它运行良好。

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

我猜它可能是节点模块的长路径或路径中的非字母字符,:,_。所以我回到React:Redux 目录并将其重命名为...React_Redux 并在/tmp/Users/Neil/Desktop/Complete Web Developer/Section 18_React_Redux/robofriends 中再次尝试npm start,它工作得很好: )

所以看起来npm 不喜欢可执行路径中的:

【讨论】:

  • 我怀疑是这样的!干得好:-)
  • 我们说话时我正在尝试
  • 就是这样!!!谢谢你,先生 :) 我真的是在反应课程的第一个视频上,所以很沮丧,我什至无法进行这么多的工作
猜你喜欢
  • 1970-01-01
  • 2019-11-19
  • 2021-01-03
  • 1970-01-01
  • 2021-02-01
  • 2021-09-26
  • 2017-02-18
  • 2019-03-18
  • 1970-01-01
相关资源
最近更新 更多