Vue-cli: vue upgrade command asks for a plugin and doesn't recognize when it is installed

Created on 31 Dec 2018  ·  17Comments  ·  Source: vuejs/vue-cli

Version

3.2.1

Environment info

  System:
    OS: Windows 10
    CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
  Binaries:
    Node: Not Found
    Yarn: Not Found
    npm: 6.2.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 44.17763.1.0
  npmGlobalPackages:
    @vue/cli: Not Found

Note that Node is absolutely installed. "node -v" reports 10.9.0.

Steps to reproduce

  1. run "vue upgrade"
  2. It reports:

    Command vue upgrade requires a global addon to be installed.
    Please run npm install -g @vue/cli-upgrade and try again.

  3. I run the above command, close the terminal, open a new one, and try it again. Same issue.

What is expected?

For it to attempt to update my CLI.

What is actually happening?

It reports what is shown in figure 3.

Most helpful comment

If we execute commands:

npm i @vue/cli @vue/cli-upgrade
vue upgrade

and get the following result:

Command vue upgrade requires a global addon to be installed.
Please run yarn global add @vue/cli-upgrade and try again.

Now we open %AppData%\npm\node_modules\@vue\cli\lib\util\loadCommand.js, navigate to line 11 catch (err2), add console.log(err2), run Vue upgrade, get the following results:

Error: Cannot find module '@vue/cli-shared-utils'

However, we can find the @vue/cli-shared-utils module in the %AppData%\Roaming\npm\node_modules\@vue\cli\node_modules\@vue\ directory.

Now let's execute commands:

npm uninstall @vue/cli @vue/cli-upgrade -g
yarn global add @vue/cli @vue/cli-upgrade
vue upgrade

and get the following result:

✔ Gathering update information...
Already up-to-date.

But one thing that puzzles me is:
The expected result could not be obtained yesterday through the following command

npm i yarn -g
yarn global add @vue/cli @vue/cli-upgrade
vue upgrade

I have to use the separate yarn installer to install yarn and then execute other commands.
But today there is no problem.

All 17 comments

Upgraded to 3.2.2, same result.

Because the official is not ready for the vue upgrade package.

If so then it is still a valid bug - the help text for the CLI should be updated to remove this until it's ready, right?

If you use the standalone installer to install yarn and then yarn global add @vue/cli @vue/cli-upgrade, you can use the vue upgrade command.
If yarn is installed via npm, then npm i @vue/cli @vue/cli-upgrade -g, the vue upgrade command will throw an error and cannot be used.
If yarn is installed via npm, then yarn global add @vue/cli @vue/cli-upgrade, the system does not recognize the vue related command and cannot be used.

I honestly have no idea what you are saying here. :) I installed the CLI via npm. I installed cli-upgrade via npm as well. I did not use Yarn at all.

If you look at the code for @vue/cli-upgrade, you'll see that it detects if it's in the yarn environment.
So, you must install yarn independently, this is required, then you must use the yarn global add @vue/cli @vue/cli-upgrade command to install @vue/cli and @vue/cli-upgrade.

Where do the docs say that Yarn is required? Heck, the docs show both npm and yarn, and npm is shown first.

If we execute commands:

npm i @vue/cli @vue/cli-upgrade
vue upgrade

and get the following result:

Command vue upgrade requires a global addon to be installed.
Please run yarn global add @vue/cli-upgrade and try again.

Now we open %AppData%\npm\node_modules\@vue\cli\lib\util\loadCommand.js, navigate to line 11 catch (err2), add console.log(err2), run Vue upgrade, get the following results:

Error: Cannot find module '@vue/cli-shared-utils'

However, we can find the @vue/cli-shared-utils module in the %AppData%\Roaming\npm\node_modules\@vue\cli\node_modules\@vue\ directory.

Now let's execute commands:

npm uninstall @vue/cli @vue/cli-upgrade -g
yarn global add @vue/cli @vue/cli-upgrade
vue upgrade

and get the following result:

✔ Gathering update information...
Already up-to-date.

But one thing that puzzles me is:
The expected result could not be obtained yesterday through the following command

npm i yarn -g
yarn global add @vue/cli @vue/cli-upgrade
vue upgrade

I have to use the separate yarn installer to install yarn and then execute other commands.
But today there is no problem.

Update:
Today I can't use the following command:

npm i yarn -g
yarn global add @vue/cli @vue/cli-upgrade
vue --version
  • vue --version

    • ~~~

           + CategoryInfo : ObjectNotFound: (vue:String) [], CommandNotFoundException

           + FullyQualifiedErrorId : CommandNotFoundException

I'm having similar issues:

npm i -g @vue/cli @vue/cli-upgrade

asks me to npm install -g @vue/clu-upgrade or, should I install yarn yarn add global @vue/cli-upgrade. Havent tried forcing yarn yet, but this should not be.

OS: Kubuntu 18.04
npm: 5.6
node: 8.12.0

@CaiPeng1989: Yes, it does detect if your in a yarn environment (or more precise, if you have yarn installed), but only to output the _correct_ error message: either npm install or yarn add. I actually dont see any other _use_ of yarn in lib/utils/loadCommand.js . As per the CommandNotFoundException, yarn global bin needs to be in the $PATH, had the same issue just now. (see here)

Update

Upgraded node & npm and all is well. Works with: npm: 6.4.1 & node: 10.15.0.

当我使用 vue upgrade 指令,等会会输出

✔ Gathering update information...
Already up-to-date.

但是没有什么效果,package.json 依赖项不变,怎么回事?

@gauseen 有可能是yarn.lock里面的版本已经是最新的了

@CaiPeng1989

$ vue info                                           

Environment Info:                                    

  System:                                            
    OS: Windows 10                                   
    CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.6
  Binaries:                                          
    Node: 10.13.0 - C:\Program Files\nodejs\node.EXE 
    Yarn: 1.12.3 - C:\Program Files (x86)\Yarn\bin\ya
    npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD     
  Browsers:                                          
    Edge: 41.16299.820.0                             
  npmPackages:                                       
    @vue/babel-preset-app:  3.0.4                    
    @vue/cli-overlay:  3.0.4                         
    @vue/cli-plugin-babel: ^3.0.4 => 3.0.4           
    @vue/cli-plugin-eslint: ^3.0.4 => 3.0.4          
    @vue/cli-plugin-unit-mocha: ^3.0.4 => 3.0.4      
    @vue/cli-service: ^3.0.4 => 3.0.4                
    @vue/cli-shared-utils:  3.0.4                    
    @vue/component-compiler-utils:  2.2.0            
    @vue/eslint-config-standard: ^3.0.4 => 3.0.4     
    @vue/preload-webpack-plugin:  1.1.0              
    @vue/test-utils: ^1.0.0-beta.20 => 1.0.0-beta.25 
    @vue/web-component-wrapper:  1.2.0               
    babel-helper-vue-jsx-merge-props:  2.0.3         
    babel-plugin-transform-vue-jsx:  4.0.1           
    eslint-plugin-vue:  4.7.1                        
    vue: ^2.5.17 => 2.5.17                           
    vue-cli-plugin-custom-config: ^0.0.3 => 0.0.3    
    vue-eslint-parser:  2.0.3                        
    vue-hot-reload-api:  2.3.1                       
    vue-lazyload:  1.2.6                             
    vue-loader:  15.4.2                              
    vue-router: ^3.0.1 => 3.0.1                      
    vue-style-loader:  4.1.2                         
    vue-template-compiler: ^2.5.17 => 2.5.17         
    vue-template-es2015-compiler:  1.6.0             
  npmGlobalPackages:                                 
    @vue/cli: Not Found                              


E:\workspace\mobile-seed (dev -> dev-org)            
$ vue upgrade                                        
✔  Gathering update information...                   
Already up-to-date.                                  

我把 yarn.lock 删除后,但是还是不行,没有效果

@gauseen package.json里面已经是最新的了,没有能够升级的插件了。你可以找一个以前创建的项目试试。

@CaiPeng1989 不是最新版本,例如: @vue/cli-service 我本地版本只有 3.0.4,但是最新的应该都 3.3.0 了

@gauseen 我把版本手动改为3.2.0就可以用
image

npm i @vue/cli @vue/cli-upgrade -g worked for me (Node 12)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghenry picture ghenry  ·  40Comments

italomaia picture italomaia  ·  88Comments

evelynhathaway picture evelynhathaway  ·  35Comments

deanilvincent picture deanilvincent  ·  38Comments

joeirimpan picture joeirimpan  ·  35Comments