vue: 'vue-cli-service' is not recognized as an internal or external command or operable program / Cannot find module 'node-sass'

Problem Description

Pull the company project code locally, and output an error after running the "npm install" command in the VSCode terminal

resolution process

  1. Help Du Niang
    tried the solutions on the Internet , the main idea is to install node-sass globally, but it didn’t work in my personal environment

  2. My personal solution
    After consulting other colleagues, I found that the version of nodejs I installed may be too high (V16.15.0).
    After uninstalling and reinstalling nodejs of V10.15.0 (you need to download other versions of nodejs, you only need to modify this The corresponding version number in the url)
    , in my personal environment to solve the "npm install" execution error problem

Replenish

After running the vue program, errors are still reported due to incorrect versions of some packages (the highest version is generally installed by default when the version number is not specified), you can try to uninstall the original package and reinstall the lower version package:

  • Method 1: Reinstall via the command line
:: 在命令行执行
npm uninstall `版本过高的包的名称` --save :: 卸载已经安装的版本过高的包
npm install `版本过高的包的名称`@`较低的版本号` --save  :: 安装较低版本的包
  • Method 2: Modify the configuration and reinstall.
    Find the package that is too high in the package.json of the project, change the version number of the configuration to a lower one, and delete the node_modules folder in the project directory (if you delete all the packages, it may take time to re-execute npm install For a long time, you can only delete the relevant packages), and then execute npm install on the command line

If you still have problems after trying a lower version, there is a high probability that a lower version is required. .Don't be afraid to toss when you encounter problems, There will always be a way if you try more! ^_^

Summarize

In vue development, the version numbers of various packages are very important... I feel that many errors come from version problems, so pay more attention

Reference URL

[1] Solutions on the network
[2] nodejs download-V10.15.0
[3] nodejs installation and environment configuration-windows

Guess you like

Origin blog.csdn.net/qq_36604536/article/details/124846080