[英]Getting Error While starting lite-server in npm
我做了一个新的“npm init”。 输入入口点:“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
系统关闭后我也面临同样的问题,因此这对我有用:
先卸载node_modules中当前本地的lite-server
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"
},
您似乎没有正确安装和配置 node/npm(PATH 问题)。
I would suggest you try to re-install Node.js using the official instructions for your platform ( https://nodejs.org/en/download/ ) or by using a Node.js version manager like nvm ( https://github.com/nvm -sh/nvm )或n ( https://github.com/tj/n )。
使用nvm或n将允许您动态切换 Node.js 版本,而无需从头开始重新安装所有内容。
只需在全球范围内安装实时服务器,我认为这应该可以解决问题。
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
我认为这应该有帮助:)
我有一个类似的问题,纱线开始工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.