If use npm build command to build a react app for production environment, we can get a build named folder. There are html, css and JavaScript in it, but the package.json file doesn’t exists.
如果使用npm build命令为生产环境构建反应应用程序,我们可以获得一个名为folder的构建。其中有html,css和JavaScript,但package.json文件不存在。
If we use this file to set http proxy endpoint to connect API, we can’t run the app well because the endpoint can’t be found.
如果我们使用此文件来设置http代理端点以连接API,我们无法很好地运行应用程序,因为无法找到端点。
How to deal with this json file rightly in this case?
在这种情况下如何正确处理这个json文件?
1 个解决方案
#1
0
First if you have package.json of some Node-React application you can run in example windows CMD (terminal console) and make some folder there you put this package.json and navigate to this folder and then, there typing npm install. On this away you can prepare all what is need for this Node-React app. Exactly with this command starting make node_modules folder there stat install need package. Next step is make folders: src and public, there you put next file : on Src folder App.js, index.js, App.css on public folder index.html. That is because in this package.json exists all what is need for starting application, but if you menually build package.json this can make with run npm. init in CMD.
Use Proxy in package.json file you can use for example if you send some data in case client-server app. There you have in client for HTTP request axios, on server side express. In package.json file add row "proxy":"http://localhost:3001" from server. For that plz. look How to set port for express server dynamically?
首先,如果您有一些Node-React应用程序的package.json,您可以在示例Windows CMD(终端控制台)中运行并在那里创建一个文件夹,您将此package.json导航到此文件夹,然后键入npm install。在此之后,您可以准备这个Node-React应用程序所需的所有内容。正好用这个命令启动make node_modules文件夹,有stat install需要的包。下一步是make文件夹:src和public,你把下一个文件放在:公共文件夹index.html上的Src文件夹App.js,index.js,App.css上。这是因为在这个package.json中存在启动应用程序所需的所有内容,但是如果你手动构建package.json,这可以通过运行npm来实现。在CMD中初始化。如果在客户端 - 服务器应用程序中发送一些数据,则可以使用package.json文件中的Proxy。在客户端有HTTP请求axios,在服务器端快递。在package.json文件中,从服务器添加行“proxy”:“http:// localhost:3001”。对于那个plz。看看如何动态设置Express服务器的端口?
#1
0
First if you have package.json of some Node-React application you can run in example windows CMD (terminal console) and make some folder there you put this package.json and navigate to this folder and then, there typing npm install. On this away you can prepare all what is need for this Node-React app. Exactly with this command starting make node_modules folder there stat install need package. Next step is make folders: src and public, there you put next file : on Src folder App.js, index.js, App.css on public folder index.html. That is because in this package.json exists all what is need for starting application, but if you menually build package.json this can make with run npm. init in CMD.
Use Proxy in package.json file you can use for example if you send some data in case client-server app. There you have in client for HTTP request axios, on server side express. In package.json file add row "proxy":"http://localhost:3001" from server. For that plz. look How to set port for express server dynamically?
首先,如果您有一些Node-React应用程序的package.json,您可以在示例Windows CMD(终端控制台)中运行并在那里创建一个文件夹,您将此package.json导航到此文件夹,然后键入npm install。在此之后,您可以准备这个Node-React应用程序所需的所有内容。正好用这个命令启动make node_modules文件夹,有stat install需要的包。下一步是make文件夹:src和public,你把下一个文件放在:公共文件夹index.html上的Src文件夹App.js,index.js,App.css上。这是因为在这个package.json中存在启动应用程序所需的所有内容,但是如果你手动构建package.json,这可以通过运行npm来实现。在CMD中初始化。如果在客户端 - 服务器应用程序中发送一些数据,则可以使用package.json文件中的Proxy。在客户端有HTTP请求axios,在服务器端快递。在package.json文件中,从服务器添加行“proxy”:“http:// localhost:3001”。对于那个plz。看看如何动态设置Express服务器的端口?