[英]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_modules
、 package-lock.json
和package.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_modules
或package.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.