Skip to main content

可用脚本

在项目目录下,你可以运行:

¥In the project directory, you can run:

npm start

在开发模式下运行应用。在浏览器中打开 http://localhost:3000 进行查看。

¥Runs the app in the development mode. Open http://localhost:3000 to view it in the browser.

如果你进行编辑,页面将重新加载。你还将在控制台中看到任何代码检查错误。

¥The page will reload if you make edits. You will also see any lint errors in the console.

npm test

在交互式监视模式下启动测试运行程序。有关详细信息,请参阅有关 运行测试 的部分。

¥Launches the test runner in the interactive watch mode. See the section about running tests for more information.

npm run build

将用于生产的应用构建到 build 文件夹。它在生产模式下正确地打包了 React,并优化了构建以获得最佳性能。

¥Builds the app for production to the build folder. It correctly bundles React in production mode and optimizes the build for the best performance.

构建被压缩并且文件名包含哈希。如有必要,可以启用类名和函数名以进行分析。有关详细信息,请参阅 生产构建 部分。

¥The build is minified and the filenames include the hashes. If necessary, classnames and function names can be enabled for profiling purposes. See the production build section for more information.

你的应用已准备好部署!有关将应用部署到流行的托管服务提供商的更多信息,请参阅有关 部署 的部分。

¥Your app is ready to be deployed! See the section about deployment for more information about deploying your application to popular hosting providers.

npm run eject

注意:这是一种单向操作。一旦你 eject,你就不能再回去了!

¥Note: this is a one-way operation. Once you eject, you can’t go back!

如果你对构建工具和配置选择不满意,可以随时 eject。此命令将从你的项目中删除单个构建依赖。

¥If you aren’t satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project.

作为代替,它会将所有配置文件和传递依赖(webpack、Babel、ESLint 等)作为 package.json 中的依赖复制到你的项目中。从技术上讲,依赖和开发依赖之间的区别对于生成静态包的前端应用来说是相当随意的。

¥Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc.) into your project as dependencies in package.json. Technically, the distinction between dependencies and development dependencies is pretty arbitrary for front-end apps that produce static bundles.

此外,它过去常常导致一些未安装开发依赖的托管平台出现问题(因此无法在服务器上构建项目或在部署前对其进行测试)。你可以根据需要自由地重新安排 package.json 中的依赖。

¥In addition, it used to cause problems with some hosting platforms that didn't install development dependencies (and thus weren't able to build the project on the server or test it right before deployment). You are free to rearrange your dependencies in package.json as you see fit.

eject 之外的所有命令仍然有效,但它们将指向复制的脚本,因此你可以调整它们。在这一点上,你是靠自己的。

¥All of the commands except eject will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

你不必使用 eject。精选的功能集适用于中小型部署,你不应该觉得必须使用此功能。但是我们知道,如果你在准备好使用时不能对其进行自定义,那么该工具将毫无用处。

¥You don’t have to ever use eject. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.