【发布时间】:2020-09-17 23:10:20
【问题描述】:
我正在尝试使用 npm 将网站部署到 gh-pages。我正在使用纯 HTML 和 CSS 以及异步 javascript。我没有使用任何 SPA 框架(反应或角度)。 我目前正在将 lite 服务器用于开发目的和 gh-pages 包。
我正在尝试使用以下命令部署 src 文件夹
npm run deploy
它失败了,因为没有指定构建脚本。 我的问题是我应该在构建脚本中写什么?
当我尝试运行npm run deploy 时,它显示以下错误
'src' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! AmrAhmed@1.0.0 build: `src`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the AmrAhmed@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Amr\AppData\Roaming\npm-cache\_logs\2020-05-30T11_30_29_824Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! AmrAhmed@1.0.0 predeploy: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the AmrAhmed@1.0.0 predeploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Amr\AppData\Roaming\npm-cache\_logs\2020-05-30T11_30_29_869Z-debug.log
在使用react的类似项目中,构建脚本有以下react-scripts build
这是我的 package.json 文件
{
"name": "AmrAhmed",
"version": "1.0.0",
"description": "",
"main": "truffle.js",
"directories": {
"test": "test"
},
"scripts": {
"dev": "lite-server",
"test": "echo \"Error: no test specified\" && exit 1",
"build": "src",
"predeploy": "npm run build",
"deploy": "gh-pages -d src"
},
"author": "",
"license": "ISC",
"devDependencies": {
"gh-pages": "^3.0.0",
"lite-server": "^2.5.4"
}
}
【问题讨论】:
标签: github npm github-pages package.json