[英]Move package.json up one dirctory in react app
I have started learning react a few days ago, I use npx create-react-app frontend to create my react app when I do so I got this structure几天前我开始学习反应,当我这样做时,我使用npx create-react-app 前端来创建我的反应应用程序,所以我得到了这个结构
-- demo
-- frontend
-- node_modules
-- public
-- src
-- .gitignore
-- package.json
-- package-lock.json
-- README.md
But what I hope to do is to move the package.json up one directory to get this structure但我希望做的是将 package.json 上移一个目录以获得此结构
-- demo
-- frontend
-- node_modules
-- public
-- src
-- .gitignore
-- package-lock.json
-- README.md
-- package.json
But when I do so I can't start the development server it says react-scripts' is not recognized as an internal or external command
and that is understandable because the react-scripts is defined in node_modules and they are now in another directory, I need to do that because heroku required package.json file be in the root folder and I need to integrate react with django, the root directory looks very messy last time when I put all django app folders and react folders in one root directory.但是当我这样做时,我无法启动开发服务器,它说
react-scripts' is not recognized as an internal or external command
,这是可以理解的,因为 react-scripts 是在 node_modules 中定义的,它们现在位于另一个目录中,我need to do that because heroku required package.json file be in the root folder and I need to integrate react with django, the root directory looks very messy last time when I put all django app folders and react folders in one root directory.
package.json reads from node_modules and both must be together, a better structure for the repo is to have a seperate pakage.json and node_modules, keep one package.json in frontend folder and one package.json in backend folder and so one package.json reads from node_modules and both must be together, a better structure for the repo is to have a seperate pakage.json and node_modules, keep one package.json in frontend folder and one package.json in backend folder and so one
--repo
--frontend
--package.json
--node_modules
--backend
--node_modules
--package.json
--readme
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.