我已经创建了一个基本的todo应用程序,它的package.json文件如下:
{
"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.com/sahil9001/to-do-app.git"
},
"keywords": [
"todo",
"app"
],
"bugs": {
"url": "https://github.com/sahil9001/to-do-app/issues"
},
"homepage": "https://github.com/sahil9001/to-do-app#readme"
}每当我运行npm test时,它会因为没有指定测试而失败,我该如何解决这个问题?此外,每当我尝试使用TRAVIS CI时,它无法检测到build脚本,我如何创建一个?
发布于 2019-10-11 04:00:53
在package.json的脚本属性中指定所有必需的脚本,如下所示
{
"name": "to-do-app",
"version": "1.0.0",
"description": "A basic to-do app created using JavaScript.",
"main": "index.js",
"scripts": {
"test": "put test command here", // example "test": "mocha test.js"
"build" : "put build command 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.com/sahil9001/to-do-app.git"
},
"keywords": [
"todo",
"app"
],
"bugs": {
"url": "https://github.com/sahil9001/to-do-app/issues"
},
"homepage": "https://github.com/sahil9001/to-do-app#readme"
}在脚本属性中没有列出任何脚本命令,只有默认值。您必须根据需要创建并放置它。有关更多详细信息,请参阅以下链接
https://www.freecodecamp.org/news/introduction-to-npm-scripts-1dbb2ae01633/
发布于 2019-10-11 04:07:59
如果你在“脚本”下查看,你会看到你的npm脚本,比如你在运行"npm test“时调用的脚本。
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},当你运行NPM init时,默认值是这个简单的回显,告诉你没有测试,你必须在这里写你自己的测试命令。
Travis未能检测到构建脚本,因为您的脚本部分中没有" build“的值,请添加如下内容:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "my_script_to_build"
},https://stackoverflow.com/questions/58330038
复制相似问题