创建React应用后,npm start不起作用。没有给出错误信息

时间:2019-11-30 11:42:07

标签: reactjs npm-start

我是新来的人,在设置新应用时遇到了一些麻烦。我在这里遵循了教程。 https://reactjs.org/docs/create-a-new-react-app.html。但是,当我去启动npm时,它没有启动,并且我没有收到任何错误。只需放回控制台即可。

在我开始创建这些应用之前,我已经创建了一些应用程序,现在当我开始使用这些应用程序时,我也遇到了同样的问题。

我已更新并安装到最新的版本

我可以访问的任何地方都有错误日志文件吗?或者我可以在运行npm start时将其登录到.txt文件

我在创建时没有任何异常。     $ npx create-react-app seatracker

Creating a new React app in C:\react_tutorial_app\nnew\seatracker.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

+ react@16.12.0
+ react-dom@16.12.0
+ react-scripts@3.2.0
added 1480 packages from 694 contributors and audited 904937 packages in 89.688s
found 0 vulnerabilities


Initialized a git repository.

Success! Created seatracker at C:\react_tutorial_app\nnew\seatracker
Inside that directory, you can run several commands:

  npm start
    Starts the development server.

  npm run build
    Bundles the app into static files for production.

  npm test
    Starts the test runner.

  npm run eject
    Removes this tool and copies build dependencies, configuration files
    and scripts into the app directory. If you do this, you can’t go back!

We suggest that you begin by typing:

  cd seatracker
  npm start

Happy hacking!

并且在启动npm时没有任何提示

R@DESKTOP-ILPL80A MINGW64 /c/react_tutorial_app/nnew/seatracker (master)
$ npm start

R@DESKTOP-ILPL80A MINGW64 /c/react_tutorial_app/nnew/seatracker (master)

我在json文件中看不到任何异常

   {
  "name": "seatracker",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-scripts": "3.2.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

3 个答案:

答案 0 :(得分:1)

此问题的原因之一可能是禁用npm安装脚本(出于安全原因)=>检查它们是否被禁用:

npm config get ignore-scripts

当前版本的create-react-app需要执行一些操作,因此,如果以上是true,我建议:

npm config set ignore-scripts false
npx create-react-app seatracker
npm config set ignore-scripts true
cd seatracker
npm start

答案 1 :(得分:-1)

我有一段时间没有使用npx了。尝试使用npm i create-react-app并使用create-react-app myapp创建应用,然后使用npm start运行应用。告诉它是否有效。

答案 2 :(得分:-1)

先尝试cd seatracker,然后再尝试npm start。 相信我。