admin管理员组文章数量:1332395
I have created a basic todo app which has package.json
file as:
{
"name": "to-do-app",
"version": "1.0.0",
"description": "A basic to-do app created using JavaScript.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Sahil Silare",
"license": "MIT",
"dependencies": {
"body-parser": "^1.19.0",
"build": "^0.1.4",
"ejs": "^2.7.1",
"express": "^4.17.1",
"npm-build": "0.0.1"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "git+.git"
},
"keywords": [
"todo",
"app"
],
"bugs": {
"url": ""
},
"homepage": ""
}
Whenever I run npm test
it fails by saying no tests specified, how can I solve this issue? also whenever I try to use TRAVIS CI
it fails to detect build
script how can I create one?
I have created a basic todo app which has package.json
file as:
{
"name": "to-do-app",
"version": "1.0.0",
"description": "A basic to-do app created using JavaScript.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Sahil Silare",
"license": "MIT",
"dependencies": {
"body-parser": "^1.19.0",
"build": "^0.1.4",
"ejs": "^2.7.1",
"express": "^4.17.1",
"npm-build": "0.0.1"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github./sahil9001/to-do-app.git"
},
"keywords": [
"todo",
"app"
],
"bugs": {
"url": "https://github./sahil9001/to-do-app/issues"
},
"homepage": "https://github./sahil9001/to-do-app#readme"
}
Whenever I run npm test
it fails by saying no tests specified, how can I solve this issue? also whenever I try to use TRAVIS CI
it fails to detect build
script how can I create one?
2 Answers
Reset to default 3Specify all required script in scripts property in package.json as below
{
"name": "to-do-app",
"version": "1.0.0",
"description": "A basic to-do app created using JavaScript.",
"main": "index.js",
"scripts": {
"test": "put test mand here", // example "test": "mocha test.js"
"build" : "put build mand here"
},
"author": "Sahil Silare",
"license": "MIT",
"dependencies": {
"body-parser": "^1.19.0",
"build": "^0.1.4",
"ejs": "^2.7.1",
"express": "^4.17.1",
"npm-build": "0.0.1"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github./sahil9001/to-do-app.git"
},
"keywords": [
"todo",
"app"
],
"bugs": {
"url": "https://github./sahil9001/to-do-app/issues"
},
"homepage": "https://github./sahil9001/to-do-app#readme"
}
You don't have any scripts mand listed in scripts property and have only default. You have to create and place it as per the need. Refer below links for more details
https://www.freecodecamp/news/introduction-to-npm-scripts-1dbb2ae01633/
https://flaviocopes./package-json/
If you look under "scripts" you'll see your npm scripts such as the script you call when you run "npm test"
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
The default value when you run NPM init is this simple echo saying no tests, you have to write your own test mand(s) here.
Travis is failing to detect a build script, because you don't have a value for "build" in your scripts section, add something like:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "my_script_to_build"
},
本文标签: javascriptHow to add build script and tests in NodeJs projectStack Overflow
版权声明:本文标题:javascript - How to add build script and tests in NodeJs project - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742279943a2445905.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论