简体   繁体   English

在反应应用程序中将 package.json 上移一个目录

[英]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.

相关问题 在Windows上,package.json中的React Create App Proxy Agent在Windows上运行缓慢 - React create app proxy agent in package.json is slow on Windows 将环境变量从package.json传递到React应用 - Pass environment variable from package.json to React app 如何在反应应用程序中从 package.json 访问主页? - How is it possible to access homepage from package.json in a react app? 我已将我的 package.json 文件在 react 项目中上移了一个文件夹,现在 `npm start` 不起作用 - I have moved my package.json file one folder up in react project and now `npm start` is not working 一个包中有多个package.json文件 - Multiple package.json files in one package 如何将反应应用程序创建为服务/包并将其导入另一个应用程序的“package.json” - How to create react app as a service/package and import it into 'package.json' of another app Package.json 变量没有被拾取 - Package.json variable not being picked up Heroku 没有为 react package.json 获取 PORT - Heroku is not getting PORT for react package.json package.json 中的自定义反应脚本无法识别 - Custom react script in package.json is not recognised 将 package.json 中使用的脚本移动到 npm ZEFE90A8E604A7C840E78D03A6ZF6 - Move script used in package.json to npm package
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM