3.1.1
8.12.0
vue add vuex
Vuex package should be installed in the node_modules folder.
Only the files were changed to have Vuex be recognized by Vue (i.e. Vue.use(Vuex)), the store.js was created as well and the package.json has the Vuex version. But the actual package was not installed in the node_modules folder which caused an error. The Terminal (Mac OS) has suggested to do an npm install vuex --save just like when vue add router was executed, but vuex-router actually got installed on the node_modules folder.
The impression was that vue add vuex would install the module as well as update files and add necessary files such as the store.js. It can take a while for some people to not realize that the module needed to be installed in the npm way because everything looked good including the package.json being updated. There are so many modules in node_modules that it can also take time just to prove to oneself that Vuex was actually not installed.
I can't quite reproduce this to the extend that you describe, but when I run vue add vuex, it does run into an error when trying to actually run npm install / yarn after having added all the files and depenency entry in package.json correctly:
Thorstens-MacBook-Pro:test-add-vuex thorstenlunborg$ vue add vuex
馃殌 Invoking generator for core:vuex...
馃摝 Installing additional dependencies...(node:41586) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'registry' of undefined
at Function.runGenerator (/Users/thorstenlunborg/.nvm/versions/node/v10.8.0/lib/node_modules/@vue/cli/lib/invoke.js:142:63)
at process._tickCallback (internal/process/next_tick.js:68:7)(node:41586) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:41586) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Thorstens-MacBook-Pro:test-add-vuex thorstenlunborg$
I get the same "UnhandledPromiseRejectionWarning" when trying to run:
vue add router
Full error:
vue add router
? Use history mode for router? (Requires proper server setup for index fallback in production) No
(node:6804) UnhandledPromiseRejectionWarning: TypeError: apply is not a function
at Generator.plugins.forEach (...node_modules\@vue\cli\lib\Generator.js:103:7)
at Array.forEach (
at new Generator (...node_modules\@vue\cli\lib\Generator.js:101:13)
at Function.runGenerator (...node_modules\@vue\cli\lib\invoke.js:116:21)
at
at process._tickCallback (internal/process/next_tick.js:189:7)
(node:6804) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6804) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
For other people stumbling across this issue, please check if you are running the command inside of the vue/cli project's root directory. I tried to run it outside of the project and got the described error.
Most helpful comment
I get the same "UnhandledPromiseRejectionWarning" when trying to run:
vue add routerFull error:)
vue add router
? Use history mode for router? (Requires proper server setup for index fallback in production) No
(node:6804) UnhandledPromiseRejectionWarning: TypeError: apply is not a function
at Generator.plugins.forEach (...node_modules\@vue\cli\lib\Generator.js:103:7)
at Array.forEach (
at new Generator (...node_modules\@vue\cli\lib\Generator.js:101:13)
at Function.runGenerator (...node_modules\@vue\cli\lib\invoke.js:116:21)
at
at process._tickCallback (internal/process/next_tick.js:189:7)
(node:6804) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6804) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.