[英]I keep getting this error while i try to use npm start on my react app
The error keeps coming up every time i use npm start.每次我使用 npm 启动时,错误都会不断出现。 i am a complete beginner我是一个完整的初学者
Traverse to my-app folder which is inside your My App folder and then run npm start
遍历到 My App 文件夹中的 my-app 文件夹,然后运行npm start
Congrats on your first react app!恭喜你的第一个反应应用程序!
The npm start
command looks in your package.json file for a script. npm start
命令在 package.json 文件中查找脚本。 It will look something like this:它看起来像这样:
'scripts': {
'start': 'node app.js'
}
Your error is saying that your terminal can't find the package.json file at all.您的错误是说您的终端根本找不到 package.json 文件。 Make sure your terminal is in the same directory as your package.json file.确保您的终端与 package.json 文件位于同一目录中。 If you type the ls
command in your terminal it should show your package.json file.如果您在终端中键入ls
命令,它应该会显示您的 package.json 文件。 If you don't see it, you can use cd..
to move up a directory, or cd {folderName}
to move down a directory.如果您没有看到它,您可以使用cd..
向上移动一个目录,或者使用cd {folderName}
向下移动一个目录。 You want to be in the my-app directory.你想在 my-app 目录中。 The pwd
command will print the directory you're currently in. pwd
命令将打印您当前所在的目录。
You have created a my app
folder inside another my app
folder, and your working directory is the first folder which doesn't have a package.json file.您已经在另一个my app
文件夹中创建了一个my app
文件夹,并且您的工作目录是第一个没有 package.json 文件的文件夹。 You must change your terminal directory to inner my app
folder.您必须将终端目录更改为my app
文件夹内部。
You need to run your command from directory which contains package.json.您需要从包含 package.json 的目录运行命令。 Probably you will also need to use command nmp run start
instead.可能您还需要使用命令nmp run start
代替。 By the way folders with spaces in names may cause some problems later.顺便说一下,名称中带有空格的文件夹可能会在以后引起一些问题。 I would recommend to remove spaces.我建议删除空格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.