我已经搜索了以前的答案,并试图解决了许多小时,但没有成功。
我输入了终端npm create-react-app
,移到了正确的CD,它给了我这个错误:
'npm ERR!缺少脚本:开始'
这是我的package.json
{
"name": "react-project",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"
}
}
对我来说这没有意义。帮助吗?
答案 0 :(得分:1)
您的package.json
缺少start
脚本。应该是
{
"name": "react-project",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"
},
"scripts": {
"start": "react-scripts start"
},
}
react-scripts start
是启动应用程序的命令。
此外,您运行了不正确的命令。应该是
npx create-react-app my-app
答案 1 :(得分:0)
不确定您是做什么的还是由什么原因引起的,但是您缺少程序包中应由create-react-app
生成的脚本:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
啊,明白了。您使用了错误的命令:
npm react-create-app
仅初始化您的package.json。您应该运行:
npm create-react-app
答案 2 :(得分:-1)
将以下内容添加到您的 package.json:
import java.awt.*;
import java.applet.*;
import java.util.*;
class Background
{
public static void showBackground(Graphics g)
{
drawWall(Graphics g);
drawTable(Graphics g);
drawTank(Graphics g);
}
private static void drawWall(Graphics g)
{
Expo.setColor(g,Expo.tan);
Expo.fillRectangle(g,0,0,1000,650);
}
private static void drawTable(Graphics g)
{
Expo.setColor(g,Expo.brown);
Expo.fillRectangle(g,125,450,175,650);
Expo.fillRectangle(g,250,450,300,650);
Expo.fillRectangle(g,700,450,750,650);
Expo.fillRectangle(g,825,450,875,650);
Expo.fillPolygon(g,125,450,225,300,775,300,875,450);
}
private static void drawTank(Graphics g)
{
Expo.setColor(g,Expo.blue);
Expo.fillRectangle(g, 250,75,750,400);
}
}