Javascript npm启动如何工作,应该是npm运行启动吗?(创建React应用程序)
在Create React App中,我们使用Javascript npm启动如何工作,应该是npm运行启动吗?(创建React应用程序),javascript,npm,create-react-app,Javascript,Npm,Create React App,在Create React App中,我们使用npm start启动我们的应用程序,但是对于构建,我们使用npm run build它应该是npm run start但是npm start如何工作。是否有任何默认的npm脚本命令?npm有许多内置命令,您可以在没有“运行”字的情况下运行这些命令,如启动、测试、发布等。另一方面,用户定义的脚本需要与“运行”字一起使用。您还可以使用内置脚本“run”,这将是相当平等的 有一组默认的内置npm脚本,可以在不使用“run”关键字的情况下执行 有些甚至在给
npm start
启动我们的应用程序,但是对于构建,我们使用npm run build
它应该是npm run start
但是npm start
如何工作。是否有任何默认的npm脚本命令?npm有许多内置命令,您可以在没有“运行”字的情况下运行这些命令,如启动、测试、发布等。另一方面,用户定义的脚本需要与“运行”字一起使用。您还可以使用内置脚本“run”,这将是相当平等的
有一组默认的内置npm脚本,可以在不使用“run”关键字的情况下执行
有些甚至在给定命令后自动运行(postinstall-在“npm安装”之后)。要完全理解这些脚本,请参阅文档
除此之外,您还可以定义可以运行的自定义脚本
- 终端支持的任何命令
- npm支持的任何命令李>
- npm启动(内置)
- npm测试(内置)
- npm运行构建(自定义)
- npm运行myinit(自定义)
- npm运行删除文件夹(自定义)
- npm运行hellovnoitkumar(定制)
//npm start, npm test
//npm run build, npm run myinit, npm run deletefolder, npm run hellovnoitkumar
//*Note that you also can define what each built in npm command does (npm start, npm test).*
{
"name": "my-webapp",
"version": "0.1.0",
"private": true,
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "^2.1.5",
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"myinit" : "npm install && npm run build && npm start",
"deletefolder": "rm -rf documents",
"hellovnoitkumar": "echo "hello vnoit kumar""
}
}
npm run start
非常常见,以至于npm实现了一个快捷方式,让您不用键入run
。
//npm start, npm test
//npm run build, npm run myinit, npm run deletefolder, npm run hellovnoitkumar
//*Note that you also can define what each built in npm command does (npm start, npm test).*
{
"name": "my-webapp",
"version": "0.1.0",
"private": true,
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "^2.1.5",
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"myinit" : "npm install && npm run build && npm start",
"deletefolder": "rm -rf documents",
"hellovnoitkumar": "echo "hello vnoit kumar""
}
}