简体   繁体   English

我已将我的 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

my current folder structure is我当前的文件夹结构是

   -- project folder
         |-- package.json
         |-- react-project
                  |-- src folder
                  |-- public folder

My node version is 18我的节点版本是 18

In order for npm start to work, you have to run the command from the same directory as your package.json .为了让npm start工作,您必须从与您的package.json相同的目录运行命令。

node_modules , package-lock.json , and package.json should always be at the root of the project as a good practice. node_modulespackage-lock.jsonpackage.json应该始终位于项目的根目录中,这是一种很好的做法。

If you move these files/folders it can disrupt the pathing of them.如果您移动这些文件/文件夹,可能会破坏它们的路径。

For example, inside package.json at the top you will a line somewhat like: "main": "node_modules/expo/AppEntry.js" .例如,在顶部的package.json中,您将有一行类似于: "main": "node_modules/expo/AppEntry.js" If you move node_modules or package.json , then this will no longer work.如果您移动node_modulespackage.json ,那么这将不再有效。 It would need to be changed to something like, "./node_modules" or "../node_modules"它需要更改为"./node_modules""../node_modules"

If there is a specific reason you need to move this folder, then you will have to do some reconfiguring to ensure the pathing is correct.如果出于特定原因需要移动此文件夹,则必须进行一些重新配置以确保路径正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 npm 开始不拾取更新的 package.json - npm start not picking up updated package.json 在我的 npm 包的 package.json 中我需要什么才能将其安装到另一个项目? - What do I need in the package.json of my npm package, to install it to another project? 如何在package.json文件中指定项目npm注册表 - How to specify project npm registry inside package.json file 在项目中有多个package.json可以吗? - is it ok to have more than one package.json in a project? 在反应应用程序中将 package.json 上移一个目录 - Move package.json up one dirctory in react app 我应该在我的 package.json 文件中放入什么来让“纱线开始”工作? - What do I put in my package.json file to get "yarn start" to work? “ npm ERR! 缺少脚本:尽管在package.json和Procfile中进行了设置,但仍在Heroku中启动 - “ npm ERR! missing script: start” at Heroku despite set up in package.json and Procfile 我将 bcrypt 安装到我的 package.json 中没有什么问题 - I have little problem installing bcrypt to my package.json 即使我的 package.json 和 node_modules 文件夹中有它们,我也得到了未定义的包 - I'm getting undefined packages even though I have them in my package.json and node_modules folder 告诉npm在特定文件夹中查找package.json - Tell npm to look for the package.json in a specific folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM