【问题标题】:Getting Error While starting lite-server in npm在 npm 中启动 lite-server 时出错
【发布时间】:2020-09-24 12:49:24
【问题描述】:

我做了一个新的“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 

【问题讨论】:

  • 为什么不只是"start": "lite-server"
  • 抱歉没用@ManuelSpigolon
  • 嗨,npm run lite 直接在终端上也失败了吗?
  • 没有同样的错误@PraveenThirumurugan
  • 您好,您能不能快速进入系统属性(搜索路径)> 环境变量> 系统变量> 路径> 编辑> 查找是否添加了NPM路径。

标签: node.js npm lite-server


【解决方案1】:

您似乎没有正确安装和配置 node/npm(路径问题)。

我建议您尝试使用适用于您平台的官方说明 (https://nodejs.org/en/download/) 或使用 Node.js 版本管理器(如 nvm (https://github.com/nvm-sh/nvm) 重新安装 Node.js或 n (https://github.com/tj/n)。

使用 nvmn,您可以动态切换 Node.js 版本,而无需从头开始重新安装所有内容。

【讨论】:

  • 我认为这是一个错误的答案。根据他的日志,npm 确实有效并调用了启动脚本。
  • 这是错误,很明显 npm 在系统 PATH 中不可用:“'npm' 不被识别为内部或外部命令、可运行程序或批处理文件。”跨度>
  • 可能只是路径问题。
  • 添加了@PraveenThirumurugan
【解决方案2】:

我有类似的问题,yarn start 工作

【讨论】:

  • 这不是问题的答案
【解决方案3】:

系统关闭后我也面临同样的问题,因此这对我有用:

先卸载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"
  },

【讨论】:

    猜你喜欢
    • 2020-06-19
    • 1970-01-01
    • 2017-01-29
    • 1970-01-01
    • 2020-07-21
    • 1970-01-01
    • 1970-01-01
    • 2016-11-01
    • 1970-01-01
    相关资源
    最近更新 更多