vue-typed-js 无法通过 npm 方式安装的问题怎么解决?

这个依赖 npm 装不下来,这个是源仓库的 package.json。主要是

{
  "name": "vue-typed-js",
  "description": "typed.js vue integration - easily create typing animations",
  "version": "0.2.0",
  "author": {
    "name": "Orlando Wenzinger",
    "email": "orlando.wenzinger@bluewin.ch"
  },
  "keywords": [
    "vue",
    "vuejs",
    "plugin"
  ],
  "repository": "https://github.com/Orlandster1998/vue-typed-js",
  "license": "MIT",
  "main": "dist/vue-typed-js.common.js",
  "unpkg": "dist/vue-typed-js.browser.js",
  "module": "index.js",
  "scripts": {
    "dev": "cross-env NODE_ENV=development webpack --config config/webpack.config.dev.js --progress --watch",
    "build": "npm run build:browser && npm run build:common",
    "build:browser": "cross-env NODE_ENV=production webpack --config config/webpack.config.browser.js --progress --hide-modules",
    "build:common": "cross-env NODE_ENV=production webpack --config config/webpack.config.common.js --progress --hide-modules",
    "prepublish": "npm run build"
  },
  "devDependencies": {
    "babel-core": "^6.0.0",
    "babel-eslint": "^7.1.1",
    "babel-loader": "^6.0.0",
    "babel-preset-es2015": "^6.14.0",
    "babel-preset-stage-0": "^6.16.0",
    "cross-env": "^3.1.3",
    "css-loader": "^0.26.1",
    "eslint": "^3.12.1",
    "eslint-config-standard": "^6.2.1",
    "eslint-loader": "^1.6.1",
    "eslint-plugin-html": "^1.6.0",
    "eslint-plugin-promise": "^3.4.0",
    "eslint-plugin-standard": "^2.0.1",
    "extract-text-webpack-plugin": "^2.0.0-beta.4",
    "node-sass": "^4.0.0",
    "sass-loader": "^4.1.0",
    "vue-loader": "^10.0.0",
    "vue-template-compiler": "^2.1.6",
    "webpack": "^2.1.0-beta.28",
    "webpack-merge": "^1.1.2"
  },
  "dependencies": {
    "typed.js": "git+https://github.com/mattboldt/typed.js.git"
  }
}

这个typed.js的 github 地址国内不能访问。
目前项目安装依赖卡在这里了,这种设置 npm 镜像也不管用,怎么解决这个问题呢?

阅读 967
avatarAI BotBETA

可以尝试以下解决方案:

  1. 修改Git镜像源(推荐):

    # 临时替换GitHub源
    git config --global url."https://hub.fastgit.org".insteadOf https://github.com
    
    # 然后重新安装依赖
    npm install
  2. 手动指定typed.js镜像源

    npm install git+https://hub.fastgit.org/mattboldt/typed.js.git
  3. 修改本地node_modules配置(长期方案):

    # 永久修改GitHub镜像
    npm config set registry https://registry.npmmirror.com
    git config --global url."https://hub.fastgit.org/".insteadOf https://github.com/
  4. 如果仍不成功,可尝试:

    # 先单独安装typed.js
    npm install git+https://gitee.com/mirrors/typed.js.git
    
    # 再安装主包时跳过依赖
    npm install vue-typed-js --no-optional --force

原理说明:该问题的根源是typed.js依赖直接从GitHub仓库拉取,国内网络访问不稳定。通过替换GitHub镜像源为国内加速源(如FastGit)可解决此问题。建议优先使用方案1,该方法不会修改项目代码,仅影响本地Git配置。

1 个回答

直接替换成

  "dependencies": {
    "typed.js": "^2.1.0"
  }
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题