您可以使用以Node.js开头的Create-React-App npm吗?

我对React和node.js非常陌生。

我想运行一个提供React.js页面/视图的node.js服务器。

当我使用'create-react-app'然后使用'npm start'时,我还需要同时启动我的节点服务器,还是需要先使用'npm run build'才能与node.js服务器一起工作?

我喜欢它在更改代码后如何在“ npm start”之后自动更新您的react.js页面。

我只是想知道每次更改时是否都必须运行“ npm run build”命令。

谢谢你的帮助!

评论
  • ererum
    ererum 回复

    No, you don't need to run npm run build command each time as this command is used when you're ready to ship your code to production environment.

    In a create-react-app project, you get hot reloading out of the box when developing locally (after running npm start). In other words, when the local server is running, every time you make a change the browser will automatically reload.

    从create-react-app文档中:

    npm start: 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.

    https://create-react-app.dev/docs/available-scripts#npm-start