economyapp@0.1.0startC:\_code\myapp>npxvue-cli-serviceservenpmERR! codeE404npmERR!404NotFound-GETregistry.npmjs.or"> "'vue-cli-service@latest' is missing from Windows npm registry but works fine in WSL"-PHP Chinese Network Q&A
"'vue-cli-service@latest' is missing from Windows npm registry but works fine in WSL"
P粉536909186
P粉536909186 2023-11-07 10:01:47
0
1
644

I have a Vue application that I'm trying to run usingnpm run start, but when I run the command from PowerShell or VS Code terminal I get the following error:

> 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

When I run thenpm run startcommand from within WSL it works fine, but when I make changes to the code the server does not hot reload. I've tried uninstalling and reinstalling the Vue CLI, and runningnpm install.

This is my package.json file:

{ "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粉536909186
P粉536909186

reply all (1)
P粉463418483

TL;DR: Runnpm install.

vue-cli-serviceis provided by@vue/cli-servicein your devDependencies. Because you didn't specify the package in thenpxcommand, it will fail if it has to look in the registry. Withoutnpx, yournpmscript will look forvue-cli-serviceinnode_modules/.bin. You can removenpxfrom thenpmscript and you should get the same result as now.

npxThe fact thatvue-cli-servicecannot be found indicates that you have not runnpm install. Run it and yournpmscript should work fine. If you don't runnpm install, you will definitely run into other problems once this is fixed.

If for some reason you want thenpmscript to work without runningnpm install, you can tellnpxin the registry Find the location of the binary file. Changenpx vue-cli-servicein thenpmscript tonpx -p @vue/cli-service vue-cli-service, this should solve the problem this problem. But you're bound to run into other problems. Regardless, you should runnpm install.

But to really get to the root of the problem, you need to figure out why there is a difference in WSL and non-WSL environments. My guess is that you have@vue/cli-serviceinstalled somewhere globally and only WSL finds it in yourPATH, but that's just a guess.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!