我做了一个新的"npm初始化“。放置入口点:"index.html“
然后安装lite-server:npm install lite-server --save-dev
我也更新了package.json,我卸载了,重新安装,尝试了一切,但它不工作,
我也尝试过npm cache clean --force,但它不起作用。任何人都可以帮助解决这个错误。
{
"name": "git-test",
"version": "1.0.0",
"description": "",
"main": "index.html",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "npm run lite",
"lite": "lite-server"
},
"author": "Sateesh",
"license": "ISC",
"dependencies": {
"lite-server": "^2.5.4"
}
}但是当我执行"npm start“时,得到了这个错误
git-test@1.0.0 start D:\Coursera\git-test
> npm run lite
'npm' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! git-test@1.0.0 start: `npm run lite`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the git-test@1.0.0 start 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\sai\AppData\Roaming\npm-cache\_logs\2020-06-05T10_20_11_723Z-debug.log 发布于 2020-09-22 14:37:59
在系统关机后,我也面临着同样的问题,因此这对我来说是有效的:
首先在node_modules中卸载当前的本地精简服务器
npm uninstall lite-server全局安装lite-server并尝试运行相同的命令
npm install -g lite-server然后点击:
npm start这为我解决了这个问题,谢谢
这是我的Json文件脚本,如果你想看看
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"lite": "lite-server"
},发布于 2020-06-05 18:33:06
您似乎没有正确安装和配置node/npm (路径问题)。
我建议您尝试使用针对您的平台的官方说明(https://nodejs.org/en/download/)重新安装Node.js,或者使用Node.js版本管理器,如nvm (https://github.com/nvm-sh/nvm)或n (https://github.com/tj/n)。
使用nvm或n,将允许您动态切换Node.js版本,而不必从头开始重新安装所有内容。
发布于 2022-01-22 05:37:40
只需在全局范围内安装live-server,我认为这应该可以解决问题。
sudo npm install --global lite-server在您的package.json文件中,您可以稍作更改。
{
"name": "git-test",
"version": "1.0.0",
"description": "",
"main": "index.html",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "lite-server",
},
"author": "Sateesh",
"license": "ISC",
"dependencies": {
"lite-server": "^2.5.4"
}
}之后,在终端上运行以下命令
npm start我认为这应该会有所帮助:)
https://stackoverflow.com/questions/62213207
复制相似问题