【问题标题】:How to run react on browser?如何在浏览器上运行反应?
【发布时间】:2021-09-21 11:20:14
【问题描述】:

我是 React 框架的新手,我正在尝试在 Tailwind CSS 的帮助下制作一个 Web 应用程序。当我按照以下步骤操作时,它会在浏览器上运行:

npx create-react-app my-project
cd my-project
npm install -D tailwindcss@npm:@tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9
npm install @craco/craco
npx tailwindcss-cli@latest init
npm start

但是当我重新打开编辑器并在终端中运行命令 npm start 时,显示以下错误:

PS D:\react1> npm start
npm ERR! Missing script: "start"
npm ERR!
npm ERR! Did you mean one of these?
npm ERR!     npm star # Mark your favorite packages
npm ERR!     npm stars # View packages marked as favorites
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\DELL\AppData\Local\npm-cache\_logs\2021-07-12T09_16_22_570Z-debug.log

请帮助我哪里错了。我按照这个页面安装了 react with tailwind https://tailwindcss.com/docs/guides/create-react-app

【问题讨论】:

  • 请也分享您的 Package.json 文件
  • 甚至 craco start 在终端中也不起作用

标签: reactjs npm tailwind-css


【解决方案1】:

试试

  1. npm 我反应脚本
  2. npm 开始

【讨论】:

    【解决方案2】:

    首先执行npm i react-scripts,然后将当前脚本替换为:

    "scripts": {
            "start": "react-scripts start",
            "build": "react-scripts build",
            "test": "react-scripts test",
            "eject": "react-scripts eject"
        },
    

    然后重新启动你的 Visual Studio 代码,并在终端中运行:npm start

    【讨论】:

      【解决方案3】:

      我收到此错误是因为我没有在特定项目目录中运行命令 npm start。 就像我的项目在:D://React/react1 我在D://React运行命令

      【讨论】:

        猜你喜欢
        • 2014-09-09
        • 2021-10-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-11
        • 2019-02-22
        • 1970-01-01
        • 2015-03-19
        相关资源
        最近更新 更多