Rumah  >  Soal Jawab  >  teks badan

"'vue-cli-service@latest' tiada daripada pendaftaran Windows npm tetapi berfungsi dengan baik dalam WSL"

Saya mempunyai aplikasi Vue yang saya cuba jalankan menggunakan npm run start, tetapi apabila saya menjalankan arahan daripada terminal PowerShell atau VS Code saya mendapat ralat berikut:

> economyapp@0.1.0 start C:_codemyapp
> npx vue-cli-service serve

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/vue-cli-service - Not found
npm ERR! 404
npm ERR! 404  'vue-cli-service@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersUserAppDataRoamingnpm-cache_logs2020-11-28T17_22_02_307Z-debug.log
Install for [ 'vue-cli-service@latest' ] failed with code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! economyapp@0.1.0 start: `npx vue-cli-service serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the economyapp@0.1.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:UsersUserAppDataRoamingnpm-cache_logs2020-11-28T17_22_02_401Z-debug.log

Apabila saya menjalankan arahan npm run start命令时,它可以正常工作,但是当我对代码进行更改时,服务器不会热重载。我尝试过卸载和重新安装Vue CLI,并运行npm install daripada WSL ia berfungsi dengan baik, tetapi apabila saya membuat perubahan pada kod pelayan tidak memuat semula panas. Saya telah cuba menyahpasang dan memasang semula Vue CLI dan menjalankan npm install.

Ini ialah fail package.json saya:

{
  "name": "myapp",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "start": "npx vue-cli-service serve",
    "build": "npx vue-cli-service build",
    "test": "npx vue-cli-service test:unit",
    "lint": "npx vue-cli-service lint",
    "serve": "npx vue-cli-service serve"
  },
  "dependencies": {
    "axios": "^0.21.0",
    "core-js": "^3.4.3",
    "lodash": "^4.17.15",
    "moment": "^2.24.0",
    "register-service-worker": "^1.6.2",
    "store2": "^2.11.1",
    "vue": "^3.0.0",
    "vue-router": "^3.1.3",
    "vuex": "^3.1.2"
  },
  "devDependencies": {
    "@types/jest": "^24.0.19",
    "@typescript-eslint/eslint-plugin": "^2.28.0",
    "@typescript-eslint/parser": "^2.28.0",
    "@vue/cli-plugin-babel": "^4.1.0",
    "@vue/cli-plugin-eslint": "^4.1.0",
    "@vue/cli-plugin-pwa": "^4.1.0",
    "@vue/cli-plugin-router": "^4.1.0",
    "@vue/cli-plugin-typescript": "^4.3.1",
    "@vue/cli-plugin-vuex": "^4.1.0",
    "@vue/cli-service": "^4.2.3",
    "@vue/devtools": "^5.3.3",
    "@vue/eslint-config-prettier": "^5.0.0",
    "@vue/eslint-config-typescript": "^5.0.2",
    "@vue/test-utils": "1.0.0-beta.29",
    "eslint": "^6.0.0",
    "eslint-plugin-prettier": "^3.1.1",
    "eslint-plugin-vue": "^6.0.0",
    "lint-staged": "^9.4.3",
    "prettier": "^1.19.1",
    "typescript": "^3.8.3",
    "vue-template-compiler": "^2.6.10"
  },
  "gitHooks": {
    "pre-commit": "lint-staged"
  },
  "lint-staged": {
    "*.{js,vue,ts}": [
      "vue-cli-service lint",
      "git add"
    ]
  }
}


P粉536909186P粉536909186346 hari yang lalu763

membalas semua(1)saya akan balas

  • P粉463418483

    P粉4634184832023-11-08 00:39:14

    TL;DR: Lari npm install.

    vue-cli-service@vue/cli-service在你的devDependencies中提供。因为你在npx命令中没有指定包,所以如果它必须在注册表中查找,它会失败。没有npx,你的npm脚本将在node_modules/.bin中查找vue-cli-service。你可以从npm脚本中移除npx, anda sepatutnya dapat hasil yang sama seperti sekarang.

    Fakta bahawa npx tidak dapat mencari vue-cli-service menunjukkan bahawa anda belum menjalankan npx找不到vue-cli-service这个事实表明你还没有运行npm install。运行它,你的npm脚本应该可以正常工作。如果不运行npm install lagi. Jalankan dan skrip npm anda akan berfungsi dengan baik. Jika anda tidak berlari

    , anda pasti akan menghadapi masalah lain sebaik sahaja anda menyelesaikan masalah ini.

    npm脚本在不运行npm install的情况下工作,你可以告诉npx在注册表中找到二进制文件的位置。将npm脚本中的npx vue-cli-service改为npx -p @vue/cli-service vue-cli-service,这样应该可以解决这个问题。但你肯定会遇到其他问题。无论如何,你都应该运行npm installJika atas sebab tertentu anda mahu skrip npm berfungsi tanpa berjalan

    , anda boleh memberitahu npx untuk mencari lokasi binari dalam pendaftaran. Tukar npx vue-cli-service dalam skrip npm kepada npx -p @vue/cli-service vue-cli-service, seperti ini Ini sepatutnya menyelesaikan masalah. Tetapi anda pasti akan menghadapi masalah lain. Tidak kira apa, anda harus berlari

    . @vue/cli-service,只有WSL在你的PATH

    Tetapi untuk benar-benar memahami punca masalah, anda perlu memikirkan mengapa terdapat perbezaan dalam persekitaran WSL dan bukan WSL. Saya rasa anda menemuinya di beberapa lokasi global yang dipasang 🎜, tetapi itu hanya tekaan. 🎜

    balas
    0
  • Batalbalas