【问题标题】:Can't run strapi and react concurrently不能同时运行strapi和反应
【发布时间】:2020-07-20 09:32:52
【问题描述】:

我正在尝试同时运行 strpi 并在 strpi 的公共目录中做出反应,但遇到了问题。

[1] npm ERR! code ELIFECYCLE
[1] npm ERR! errno 1
[1] npm ERR! public@0.1.0 start: `react-scripts start`
[1] npm ERR! Exit status 1
[1] npm ERR!
[1] npm ERR! Failed at the public@0.1.0 start script.
[1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[1]
[1] npm ERR! A complete log of this run can be found in:
[1] npm ERR!     C:\Users\---\AppData\Roaming\npm-cache\_logs\2020-07-20T09_22_38_328Z-debug.log
[1] npm ERR! code ELIFECYCLE
[1] npm ERR! errno 1
[1] npm ERR! react-strapi@0.1.0 client: `npm start --prefix public`
[1] npm ERR! Exit status 1
[1] npm ERR!
[1] npm ERR! Failed at the react-strapi@0.1.0 client script.
[1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[1]
[1] npm ERR! A complete log of this run can be found in:
[1] npm ERR!     C:\Users\---\AppData\Roaming\npm-cache\_logs\2020-07-20T09_22_38_408Z-debug.log

【问题讨论】:

    标签: node.js reactjs npm strapi concurrently


    【解决方案1】:

    你的 Strapi 应用和 react-app 是相互独立的吗?如果是这样,那么启动你的 React 应用程序与 Strapi 无关应该没有问题,因为 Strapi 本质上应该是你的后端,而你的 React 应用程序是前端。你的 React 应用可以单独运行吗?

    【讨论】:

    • 不,我只想在同一个终端同时运行 react 和strapi,但不运行
    • 您应该将它们分开,因为 React 应用程序应该调用您的后端 Strapi 应用程序。如果两个项目都在同一个文件夹中,那么只要**它们都被分开**到它们自己的文件夹(客户端和服务器)中并且每个都独立运行就可以了。您仍然可以同时运行它们;您导航到 Stapi 应用程序目录并运行它,然后在另一个终端窗口中运行您的 React 应用程序。你可以修改一个脚本,用一个命令同时运行它们,但我建议的方法应该更容易
    • strapi 还有其他简单的替代前端吗?
    • Strapi 是一个无头 CMS,因此如果您在使用该软件包时已经喜欢它,它有一个“前端”。 Strapi 所做的就是以视觉上吸引人的方式管理您的内容(您的 BE);并且您单独的前端应用程序(React 等)将从后端接收此数据并以您所需的格式显示它。这里是Strapi docs
    猜你喜欢
    • 2019-07-31
    • 1970-01-01
    • 1970-01-01
    • 2020-07-07
    • 2018-08-25
    • 2014-07-29
    • 2013-04-16
    • 2018-11-30
    • 1970-01-01
    相关资源
    最近更新 更多