[英]How to run nodejs project in package.json
I am working on Nodejs and right now i am trying to run nodejs project (existing), how can i do this?我正在使用 Nodejs,现在我正在尝试运行 nodejs 项目(现有),我该怎么做? Here is my package.json这是我的 package.json
"scripts": {
"test": "jest",
"build": "tsc",
"lint": "eslint . --ext .ts,.js,.md -c .eslintrc.json --fix",
"prepublishOnly": "npm run build",
"dev": "next dev",
},
I tried with following code but not working,How can i do this?我尝试使用以下代码但无法正常工作,我该怎么做?
npm jest
First clean this up首先清理这个
"scripts": {
"test": "jest",
"build": "tsc",
"lint": "eslint . --ext .ts,.js,.md -c .eslintrc.json --fix",
"prepublishOnly": "npm run build",
"dev": "next dev" // notice i removed the trailing comma here
},
Once that is set, run your commands一旦设置好,运行你的命令
To start your project开始你的项目
npm run dev
To run your tests运行你的测试
npm run test
The idea is basically npm run [script]
这个想法基本上是npm run [script]
To run your project:要运行您的项目:
npm run dev
To run unit tests:要运行单元测试:
npm run test
You can run your scripts in the terminal with the npm run [script]
command.您可以使用npm run [script]
命令在终端中运行脚本。 In your case, run npm run test
.在您的情况下,运行npm run test
。
You can run any scripts.您可以运行任何脚本。 It has to be defined in package.json file For example define your package.json as shown below:它必须在 package.json 文件中定义 例如定义您的 package.json 如下所示:
"scripts" :{
"start": "node index.js",
"test" : "mocha test/**.spec.ts"
}
Once it's defined you can run
npm run start -> to start up your server
npm run test -> to run unit test using mocha(just an example)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.