Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue: Add Vue3 support #10654

Closed
p3k opened this issue May 5, 2020 · 157 comments
Closed

Vue: Add Vue3 support #10654

p3k opened this issue May 5, 2020 · 157 comments

Comments

@p3k
Copy link

p3k commented May 5, 2020

I just tried to run storybook with a Vue3 (beta) app and got some errors… A few I was able to work-around merging our Webpack config and pushing the Vue3 loader plugin:

const wltConfig = require('../apps/webpack-dev');
const { VueLoaderPlugin } = require('vue-loader');

module.exports = {
	stories: ['../**/*.stories.[tj]s'],

	webpackFinal: (config, ...args) => {
		config.plugins.push(new VueLoaderPlugin());
		return { ...config, module: { ...config.module, rules: wltConfig().module.rules } };
	}
};

I still get a warning and an error in the shell:

WARN   Failed to load preset: "/home/tobi/Projects/modul/portal/client/node_modules/@storybook/vue/dist/server/framework-preset-vue.js"
ERR! Error: Cannot find module 'vue-loader/lib/plugin'

– nevertheless storybook builds and opens the browser. There I am stuck with this error message:

Uncaught TypeError: _vue.default is not a constructor
    at Object../node_modules/@storybook/vue/dist/client/preview/render.js (render.js:43)
    at __webpack_require__ (bootstrap:848)
    at fn (bootstrap:150)
    at Object../node_modules/@storybook/vue/dist/client/preview/index.js (index.js:24)
    at __webpack_require__ (bootstrap:848)
    at fn (bootstrap:150)
    at Object.<anonymous> (index.js:55)
    at Object../node_modules/@storybook/vue/dist/client/index.js (index.js:59)
    at __webpack_require__ (bootstrap:848)
    at fn (bootstrap:150)

Is there a better approach than this? I am a total n00b to storybook so would be glad about any pointer or assistance. (I searched the issues for vue3 without any meaningful results, at least as far as I can tell.)

@pksunkara
Copy link
Member

Hmm.. We might need to do a vue3 preset

@p3k
Copy link
Author

p3k commented May 7, 2020

Hmm.. We might need to do a vue3 preset

can i help?

@p3k
Copy link
Author

p3k commented May 11, 2020

what i tried so far (only in dist files located in the node modules directory, though):

vue/dist/server/framework-preset.js

  • VueLoaderPlugin is now an export of vue-loader
  • replace vue-esm.js with vue.esm-browser.js
11c11
< var _plugin = _interopRequireDefault(require("vue-loader/lib/plugin"));
---
> var _plugin = _interopRequireDefault(require("vue-loader").VueLoaderPlugin);
34c34
<         vue$: require.resolve('vue/dist/vue.esm.js')
---
>         vue$: require.resolve('vue/dist/vue.esm-browser.js')

vue/dist/client/preview/render.js

app component is now instantiated with createApp(), all configuration etc. needs to be applied to the instance

21c21
< var _vue = _interopRequireDefault(require("vue"));
---
> var _vue = _interopRequireDefault(require("vue").createApp);
43c43
< var root = new _vue["default"]({
---
> var root = _vue["default"]({
67c67
<   _vue["default"].config.errorHandler = showException;
---
>   root.config.errorHandler = showException;
88c88
<     root.$mount('#root');
---
>     root.mount('#root');

i am now stuck with vue/dist/client/preview/index.js because the app instance is needed there, e.g. to define the extends property – and that seems only feasible to implement with a proper storybook build…

Screenshot-2020-05-11-10:41:14

hopefully these baby steps are of some use.

@stale
Copy link

stale bot commented Jun 2, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Jun 2, 2020
@p3k
Copy link
Author

p3k commented Jun 2, 2020

bump

@stale stale bot removed the inactive label Jun 2, 2020
@shilman shilman changed the title What’s the state of supporting Vue3? Vue: Add Vue3 support Jun 6, 2020
@shilman
Copy link
Member

shilman commented Jun 6, 2020

@pksunkara @graup @Aaron-Pool does anybody have time to dig into this? if there are breaking changes we need and we can get those into 6.0, now would be the best time to do it!

@pksunkara
Copy link
Member

We would still need to support Vue2 for quite a while after Vue3 is released. One thing we need to check is if we can somehow support both of them at the same time.

Also considering that Vue3 is not yet out of beta, and supposing that we want to get storybook v6 out, I would postpone the vue3 support to be after the v6 release

@graup
Copy link
Contributor

graup commented Jun 6, 2020

I'm planning to look into this soon, but can't give an ETA. Haven't had a chance to try Vue 3 yet.

I agree with @pksunkara that this isn't urgent for 6.0 as it's still beta anyway.

@shilman
Copy link
Member

shilman commented Jun 6, 2020

Thanks @graup. I also agree it isn't urgent -- we shouldn't be expected to support unreleased software in Storybook. My only concern is that, for example, we release 6.0 in July, Vue3 launches in August, we go to support it in September, and find that there's a breaking change required. And we can't get that breaking change in without a major version bump in October, which should be happening in June 2021 instead.

@milewski
Copy link

milewski commented Jun 6, 2020

I was just trying to get some lights on the discord channel just now on how do I go to attempt to make it work with Vue 3, it would require a new preset as the logic to bootstrap the framework is a bit different.. I dont think the current code in the vue folder will work with vue 3..

@pksunkara
Copy link
Member

I understand @shilman. Let me clarify a bit more since it looks I didn't get my point across correctly.

From what I understand with @p3k's attempts and @milewski's comment, we not only need a new preset but we also need to do breaking changes in the @storybook/vue package.

But we would still need to support Vue v2 for quite a while, not everyone would be moving to Vue v3. So, unless we want to say that Vue v2 is not supported anymore, it would be better if we create a new @storybook/vue3 package.

But if we do decide to cut off Vue v2 support, then yes, I agree that we should probably do breaking changes before Storybook v6.

@shilman
Copy link
Member

shilman commented Jun 6, 2020

@pksunkara Your proposed solution sounds great. 💯

I don't think we can cut off vue2 support anytime soon, so we would want to run those two packages in parallel, and maybe make a full cut-over in some future major release (7.0? 8.0? never?). After the two packages are released we can use npm download stats to determine when is the right time to remove Vue2 support. WDYT?

cc @ndelangen

@milewski
Copy link

milewski commented Jun 6, 2020

I gave it a shoot: https://github.com/milewski/storybook/tree/vue3 this is essentially working for me with vue3 ..

however, there was a block of code that I'm unsure what it was supposed to do https://github.com/milewski/storybook/blob/vue3/app/vue/src/client/preview/index.ts#L41-L58 I haven't actually used storybook ever before.. I just wanted to start using it now with my vue3 project..

so as far as I can tell https://storybook.js.org/docs/guides/guide-vue/ following the instruction on this guide I got my component using vue 3 rendered successfully... without that piece of code I left off... Perhaps it is needed to work with some specific plugin? can someone tell me with which config/addon/plugin that code would be useful for? so I can find a way to fix that and someone can get some inspiration on my version and properly follow the code procedures to release a new preset in here?

@shilman
Copy link
Member

shilman commented Jun 6, 2020

Great work @milewski -- super exciting!!! 🚀

@milewski
Copy link

milewski commented Jun 7, 2020

I figured out what that code did.. it was necessary to apply the options given from knobs .. i have fixed that .. can you try it out as it seems you have been using storybook for longer? @p3k

You can install it by running:

git clone --branch vue3 https://github.com/milewski/storybook.git
cd storybook
yarn bootstrap --core
yarn build (select vue)
cd app/vue
yarn link

then cd to your project and:

yarn link @storybook/vue

@p3k
Copy link
Author

p3k commented Jun 8, 2020

thanks a lot for your efforts @milewski – i am just trying out your branch and got an error when running yarn bootstrap --core:

…
$ node ../../scripts/prepare.js
TSFILE: /home/tobi/Projects/modul/storybook/app/mithril/dist/src/client/preview/globals.d.ts
TSFILE: /home/tobi/Projects/modul/storybook/app/mithril/dist/src/client/preview/types.d.ts
TSFILE: /home/tobi/Projects/modul/storybook/app/mithril/dist/src/client/preview/render.d.ts
TSFILE: /home/tobi/Projects/modul/storybook/app/mithril/dist/src/client/preview/index.d.ts
TSFILE: /home/tobi/Projects/modul/storybook/app/mithril/dist/src/client/index.d.ts
Built: @storybook/mithril@6.0.0-beta.22
lerna ERR! yarn run prepare exited 1 in '@storybook/vue'
lerna ERR! yarn run prepare stdout:
$ node ../../scripts/prepare.js
src/server/framework-preset-vue.ts(5,17): error TS4058: Return type of exported function has or is using name 'VueLoaderPlugin' from external module "/home/tobi/Projects/modul/storybook/app/vue/node_modules/vue-loader/dist/plugin" but cannot be named.
TSFILE: /home/tobi/Projects/modul/storybook/app/vue/dist/client/preview/globals.d.ts
TSFILE: /home/tobi/Projects/modul/storybook/app/vue/dist/client/preview/types.d.ts
TSFILE: /home/tobi/Projects/modul/storybook/app/vue/dist/client/preview/render.d.ts
TSFILE: /home/tobi/Projects/modul/storybook/app/vue/dist/client/preview/util.d.ts
TSFILE: /home/tobi/Projects/modul/storybook/app/vue/dist/client/preview/index.d.ts
TSFILE: /home/tobi/Projects/modul/storybook/app/vue/dist/client/index.d.ts
TSFILE: /home/tobi/Projects/modul/storybook/app/vue/dist/server/options.d.ts
TSFILE: /home/tobi/Projects/modul/storybook/app/vue/dist/server/build.d.ts
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

lerna ERR! yarn run prepare stderr:
ERR! FAILED (ts) :  
ERR! FAILED to compile ts: @storybook/vue@6.0.0-beta.22 
error Command failed with exit code 1.

lerna ERR! yarn run prepare exited 1 in '@storybook/vue'
lerna WARN complete Waiting for 3 child processes to exit. CTRL-C to exit immediately.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@milewski
Copy link

milewski commented Jun 8, 2020

Uhm. There was an issue with typescript. I just disabled the ts checking for now.. pull the latest code from my branch and try again

@phated
Copy link
Contributor

phated commented Feb 15, 2021

@alex-w0 I'm not sure what you mean, the other packages are just addons that you might want to use. You can't use the "latest" version of the CLI to init a Vue 3 project, you need to use @next

@alex-w0
Copy link

alex-w0 commented Feb 16, 2021

@phated Thanks, that works. I was just a bit confused because the readme of the package is still targeting to the latest version of the cli command.

@livthomas
Copy link
Contributor

I started using NPM 7 and everything worked fine until I tried to update Storybook dependencies:

npm ERR! Found: vue@3.0.5
npm ERR! node_modules/vue
npm ERR!   vue@"^3.0.5" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^2.6.8" from @storybook/vue@6.2.0-alpha.28
npm ERR! node_modules/@storybook/vue
npm ERR!   peerOptional @storybook/vue@"6.2.0-alpha.28" from @storybook/addon-essentials@6.2.0-alpha.28
npm ERR!   node_modules/@storybook/addon-essentials
npm ERR!     dev @storybook/addon-essentials@"^6.2.0-alpha.28" from the root project

It looks like @storybook/addon-essentials has @storybook/vue as a peer dependency. NPM 7 automatically installs all peer dependencies and it fails on @storybook/vue because I use newer version of Vue.js than the one this package expects.

Can you please remove the dependency between @storybook/addon-essentials and @storybook/vue?

@phated
Copy link
Contributor

phated commented Feb 16, 2021

@livthomas unfortunately, the way everything is laid out right now, it is required to have the peerDependencies. @shilman and I were already talking about ways to make those go away because we are having issues supporting Vue 2 and Vue 3 in parallel and this might be the thing that pushes that work to the forefront.

In the meantime, you probably want to create an npmrc in your project that sets the --legacy-peer-deps option so you don't have that collision (storybook has a TON of peerDeps). Check out https://docs.npmjs.com/cli/v7/commands/npm-install#configuration for more information.

@phated
Copy link
Contributor

phated commented Feb 16, 2021

@alex-w0 Yeah, unfortunately, we don't have an automated way to keep the docs in-sync between "next" and "master", so we just keep everything referencing the happy-path and have things be a little more friction for users on the alpha/beta/rc releases. Sorry about that.

@shilman
Copy link
Member

shilman commented Feb 16, 2021

@merceyz you added the @storybook/vue peer dep to @storybook/addon-essentials here: #12461

AFAICT essentials itself doesn't depend on vue, but it depends on docs, which has an optional peer dep on vue. Is there any chance we can remove the peer dep from essentials? See @livthomas 's comment above.

@merceyz
Copy link
Contributor

merceyz commented Feb 16, 2021

AFAICT essentials itself doesn't depend on vue, but it depends on docs, which has an optional peer dep on vue. Is there any chance we can remove the peer dep from essentials?

@shilman I think this is just a bug with npm, but without a repro I can't really test anything to answer either

NPM 7 automatically installs all peer dependencies and it fails on @storybook/vue

@livthomas It shouldn't do that for optional peer dependencies, if it does you should file a bug report with npm

@Blackfaded
Copy link

Blackfaded commented Feb 17, 2021

When rendering a vue 3 component I get the error

Bildschirmfoto 2021-02-17 um 15 38 13

My Setup:

"dependencies": {
    "@ionic/core": "^5.5.4",
    "vue": "^3.0.0",
    "vue-router": "^4.0.0-0",
    "vuex": "^4.0.0-0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.16",
    "@storybook/addon-actions": "^6.2.0-alpha.28",
    "@storybook/addon-essentials": "^6.2.0-alpha.28",
    "@storybook/addon-links": "^6.2.0-alpha.28",
    "@storybook/vue3": "^6.2.0-alpha.28",
    "@types/jest": "^24.0.19",
    "@typescript-eslint/eslint-plugin": "^2.33.0",
    "@typescript-eslint/parser": "^2.34.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-plugin-router": "~4.5.0",
    "@vue/cli-plugin-typescript": "~4.5.0",
    "@vue/cli-plugin-unit-jest": "~4.5.0",
    "@vue/cli-plugin-vuex": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/compiler-sfc": "^3.0.0",
    "@vue/eslint-config-typescript": "^5.0.2",
    "@vue/test-utils": "^2.0.0-0",
    "babel-loader": "^8.2.2",
    "eslint": "^6.7.2",
    "eslint-import-resolver-typescript": "^2.3.0",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-vue": "^7.0.0-0",
    "sass": "^1.26.5",
    "sass-loader": "^8.0.2",
    "typescript": "~3.9.3",
    "vue-jest": "^5.0.0-0"
  }

Story:

import myButton from './Button.vue';

export default {
  title: 'Components/Button',
  component: myButton,
  argTypes: {},
};

const Template = () => ({
  components: { myButton },
  template: '<my-button />',
});

export const Primary = Template.bind({});

Component:

<template>
  <button>Button</button>
</template>

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  name: "Button",
});
</script>

Has anyone faced a similar issue yet?

@Blackfaded
Copy link

Okay, I had to install the vue-loader >= 16

@markus-gx
Copy link

Okay, I had to install the vue-loader >= 16

you mean vue-loader-v16package? Because the latest version of vue-loader is 15.9.6.

It still does not run on my machine. Same error you had.

@livthomas
Copy link
Contributor

@geilix10 The version marked as latest is 15.9.6. But the actual latest version is 16.1.2 which is marked as next. Just run the following command and you will get what you need:

npm i -D vue-loader@next

@petervmeijgaard
Copy link

petervmeijgaard commented Feb 23, 2021

@geilix10 I was probably having the same problem as you. Did you also try installing the dependencies using Yarn instead of NPM? I ran into the same problem.

I added vue-loader using yarn add -D vue-loader@next, but somehow the old version was still being used for Storybook. I was able to run yarn storybook just fine, but once I removed the node_modules directory, and ran yarn again, the following warning was shown:

warning Pattern ["vue-loader@^16.1.2"] is trying to unpack in the same destination [...]

When I ran yarn storybook afterward, the same error was shown as the one you're experiencing.

I was able to fix this by adding the following section to my package.json:

"resolutions": {
  "vue-loader": "^16.1.2"
},

By doing this, you're "forcing" Yarn to use vue-loader@^16.1.2 instead of the older version

I hope this fixes the issue for you as well!

@F0rsaken
Copy link

F0rsaken commented Mar 11, 2021

For anyone having problem with Storybook with Vue 3 + TypeScript, here's what I did:

  1. Add SB to project npx sb@next init
  2. Remove generated folder src/storybook that contains examples, as it broke my compilation (don't know why)
  3. As suggested above, install vue loader yarn add -D vue-loader@next
  4. In package.json:
  "resolutions": {
    "vue-loader": "^16.0.0"
  }

Adding ^16.1.2 don't work for me (still don't know why)
5. Remove all node_modules and install them again [EDIT: it's not necessary]
6. Modify .storybook/main.js as below, to enable alias resolution and sass loading:

const path = require('path');

module.exports = {
  "stories": [
    "../src/**/*.stories.mdx",
    "../src/**/*.stories.@(js|jsx|ts|tsx)"
  ],
  "addons": [
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    "@storybook/addon-postcss"
  ],
  webpackFinal: async (config, { configType }) => {
    config.module.rules.push({
      test: /\.scss$/,
      use: ['style-loader', 'css-loader', 'sass-loader'],
      include: path.resolve(__dirname, '../'),
    });

    config.resolve.alias = {
      '@': path.resolve(__dirname, "../src")
    }

    return config;
  },
}
  1. run yarn storybook and you should be fine!

@Blackfaded
Copy link

Blackfaded commented Mar 11, 2021

In addition to the above comment I can add, that the vue-style-loader enabled me to use scss mixins in the style tag:

  config.module.rules.push({
    test: /\.scss$/,
    use: [
      'vue-style-loader',
      'css-loader',
      {
        loader: 'sass-loader',
        options: {
          additionalData: `
          @import "@/libs/ui/styles/variables.scss";
          @import "@/libs/ui/styles/global.scss";
					`,
        },
      },
    ],
  });

@avesus
Copy link

avesus commented Jan 6, 2022

The installation broke our existing project in Quasar:

TypeError: Cannot read properties of undefined (reading 'parseComponent')

  - parse.js:15 parse
  
[vue-loader] vue-template-compiler must be installed as a peer dependency, or a compatible compiler implementation must be passed via options

Update

Running the yarn add -D vue-loader@next command fixes the problem.

@shilman
Copy link
Member

shilman commented Jan 7, 2022

@avesus I realize you already fixed it, but I just merged #14624, can you please try upgrading to 6.5 and see if that fixes it?

npx sb@next upgrade --prerelease

@christianwiedemann
Copy link
Contributor

@shilman No got the message: ERR! Error: Cannot find module 'vue/dist/vue.esm-bundler.js' after running npx sb@next upgrade --prerelease

Here my package.json

{
  "name": "workroom",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "devDependencies": {
    "@babel/core": "^7.16.10",
    "@storybook/addon-actions": "^6.5.0-alpha.22",
    "@storybook/addon-essentials": "^6.5.0-alpha.22",
    "@storybook/addon-links": "^6.5.0-alpha.22",
    "@storybook/vue3": "^6.5.0-alpha.22",
    "babel-loader": "^8.2.3",
    "vue-loader": "^16.8.3"
  },
  "dependencies": {},
  "scripts": {
    "storybook": "start-storybook -p 6006",
    "build-storybook": "build-storybook"
  }
}

@christianwiedemann
Copy link
Contributor

Ah sorry I have to add (this was not added by npx init) than it works

  "dependencies": {
    "core-js": "^3.6.5",
    "vue": "^3.0.0"
  },

@noff
Copy link

noff commented Feb 14, 2022

Hello.
Just installed from scratch Nuxt3 with Vue3. Then installed storybook (and then tried to run this npx sb@next upgrade --prerelease)

Now get this:

$ yarn storybook                  
yarn run v1.22.10
$ start-storybook -p 6006
info @storybook/vue v6.5.0-alpha.39
info 
info => Loading presets
ERR! Error: Cannot find module '/home/.../node_modules/vue/dist/vue.esm.js'

Same issue was before I run npx sb@next upgrade --prerelease.

Repo is here: https://github.com/noff/nuxt3storybook

@lukastillmann
Copy link

I have the same issue after upgrading an existing repo to vue3.

After running npx sb@next upgrade --prerelease I still get the following error message

Error: Cannot find module '/home/lukas/vue-sound/node_modules/vue/dist/vue.esm.js' .

This is my package.json

{
  "dependencies": {
    "@storybook/addon-a11y": "^6.5.0-alpha.45",
    "@vue/compat": "3.2.13",
    "@vue/composition-api": "^1.4.6",
    "core-js": "^3.21.1",
    "dayjs": "^1.10.7",
    "focus-visible": "^5.2.0",
    "prettier-plugin-jsdoc": "^0.3.30",
    "register-service-worker": "^1.7.2",
    "vue": "^3.2.13",
    "vue-router": "^4.0.3",
    "vuex": "^4.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.17.5",
    "@babel/eslint-parser": "^7.12.16",
    "@storybook/addon-actions": "^6.5.0-alpha.45",
    "@storybook/addon-essentials": "^6.5.0-alpha.45",
    "@storybook/addon-links": "^6.5.0-alpha.45",
    "@storybook/vue": "^6.5.0-alpha.45",
    "@vue/cli-plugin-babel": "~5.0.0",
    "@vue/cli-plugin-eslint": "~5.0.0",
    "@vue/cli-plugin-pwa": "~5.0.0",
    "@vue/cli-plugin-router": "~5.0.0",
    "@vue/cli-plugin-unit-jest": "~5.0.0",
    "@vue/cli-plugin-vuex": "~5.0.0",
    "@vue/cli-service": "~5.0.0",
    "@vue/eslint-config-prettier": "^6.0.0",
    "@vue/test-utils": "^2.0.0-0",
    "babel-eslint": "^10.1.0",
    "babel-loader": "^8.2.3",
    "compression-webpack-plugin": "^6.1.1",
    "eslint": "^7.32.0",
    "eslint-config-prettier": "^8.4.0",
    "eslint-import-resolver-alias": "^1.1.2",
    "eslint-plugin-import": "^2.25.4",
    "eslint-plugin-prettier": "^4.0.0",
    "eslint-plugin-storybook": "^0.5.7",
    "eslint-plugin-vue": "^8.5.0",
    "jsdoc-vuejs": "^4.0.0",
    "lint-staged": "^9.5.0",
    "prettier": "^2.5.1",
    "sass": "^1.49.8",
    "sass-loader": "^12.0.0",
    "storybook-vue-router": "^1.0.7",
    "vue-loader": "^16.8.3",
    "vue-svg-loader": "^0.17.0-beta.2"
  }
}

@prathamesh-gharat
Copy link

I ran into the same issue.

Error: Error: Cannot find module 'vue/dist/vue.esm-bundler.js'

My observations.
\Storybook-inst\node_modules\@storybook\vue3\dist\cjs\server\framework-preset-vue3.js references vue/dist/vue.esm-bundler.js in a line vue$: require.resolve('vue/dist/vue.esm-bundler.js')

But \Storybook-inst\node_modules\vue is missing. i.e. vue package is missing.

npm i -D vue@latest and then npm run storybook works for me at least.

P.S. I had already tried npx sb@next upgrade --prerelease before I installed vue@latest as a dev dependency, but it didn't work.

@lukastillmann
Copy link

npm i -D vue@latest and then npm run storybook works for me at least.

This worked for you? I also tried installing vue as a dev dependency, but the error persists, when I run npm run storybook

Have you done anything else to get it to work? What package versions have you installed now?

@lukastillmann
Copy link

I just noticed, we have different error.

Cannot find module '/home/lukas/vue-sound/node_modules/vue/dist/vue.esm.js'

This file is no longer part of the vue package. But storybook tries to import it here:

// ./node_modules/@storybook/vue/dist/cjs/server/framework-preset-vue.js:53

config.resolve.alias = _objectSpread(_objectSpread({}, config.resolve.alias), {}, {
  vue$: require.resolve('vue/dist/vue.esm.js')
});

This is my error stack:

ERR! Error: Cannot find module '/home/lukas/vue-sound/node_modules/vue/dist/vue.esm.js'                                                                                       ERR!     at createEsmNotFoundErr (internal/modules/cjs/loader.js:929:15)                                                                                                      ERR!     at finalizeEsmResolution (internal/modules/cjs/loader.js:922:15)
ERR!     at resolveExports (internal/modules/cjs/loader.js:450:14)
ERR!     at Function.Module._findPath (internal/modules/cjs/loader.js:490:31)
ERR!     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)
ERR!     at Function.resolve (internal/modules/cjs/helpers.js:98:19)
ERR!     at Object.webpack (/home/lukas/vue-sound/node_modules/@storybook/vue/dist/cjs/server/framework-preset-vue.js:53:19)
ERR!     at async starterGeneratorFn (/home/lukas/vue-sound/node_modules/@storybook/builder-webpack4/dist/cjs/index.js:135:16)
ERR!     at async Object.start (/home/lukas/vue-sound/node_modules/@storybook/builder-webpack4/dist/cjs/index.js:275:14)
ERR!     at async Promise.all (index 0)
ERR!     at async storybookDevServer (/home/lukas/vue-sound/node_modules/@storybook/core-server/dist/cjs/dev-server.js:139:28)
ERR!     at async buildDevStandalone (/home/lukas/vue-sound/node_modules/@storybook/core-server/dist/cjs/build-dev.js:118:31)
ERR!     at async buildDev (/home/lukas/vue-sound/node_modules/@storybook/core-server/dist/cjs/build-dev.js:164:5)
ERR!  Error: Cannot find module '/home/lukas/vue-sound/node_modules/vue/dist/vue.esm.js'
ERR!     at createEsmNotFoundErr (internal/modules/cjs/loader.js:929:15)
ERR!     at finalizeEsmResolution (internal/modules/cjs/loader.js:922:15)
ERR!     at resolveExports (internal/modules/cjs/loader.js:450:14)
ERR!     at Function.Module._findPath (internal/modules/cjs/loader.js:490:31)
ERR!     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)
ERR!     at Function.resolve (internal/modules/cjs/helpers.js:98:19)
ERR!     at Object.webpack (/home/lukas/vue-sound/node_modules/@storybook/vue/dist/cjs/server/framework-preset-vue.js:53:19)
ERR!     at async starterGeneratorFn (/home/lukas/vue-sound/node_modules/@storybook/builder-webpack4/dist/cjs/index.js:135:16)
ERR!     at async Object.start (/home/lukas/vue-sound/node_modules/@storybook/builder-webpack4/dist/cjs/index.js:275:14)
ERR!     at async Promise.all (index 0)
ERR!     at async storybookDevServer (/home/lukas/vue-sound/node_modules/@storybook/core-server/dist/cjs/dev-server.js:139:28)
ERR!     at async buildDevStandalone (/home/lukas/vue-sound/node_modules/@storybook/core-server/dist/cjs/build-dev.js:118:31)
ERR!     at async buildDev (/home/lukas/vue-sound/node_modules/@storybook/core-server/dist/cjs/build-dev.js:164:5) {
ERR!   code: 'MODULE_NOT_FOUND',
ERR!   path: '/home/lukas/vue-sound/node_modules/vue/package.json'
ERR! }

And my package.json

{
  "dependencies": {
    "@storybook/addon-a11y": "^6.5.0-alpha.61",
    "@vue/compat": "3.2.13",
    "@vue/composition-api": "^1.4.6",
    "core-js": "^3.21.1",
    "dayjs": "^1.10.7",
    "focus-visible": "^5.2.0",
    "lottie-web": "^5.8.1",
    "prettier-plugin-jsdoc": "^0.3.30",
    "register-service-worker": "^1.7.2",
    "swipejs": "^2.3.1",
    "urijs": "^1.19.8",
    "uuid": "^8.3.2",
    "v-show-slide": "^1.8.3",
    "vue-router": "^4.0.3",
    "vuex": "^4.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.17.5",
    "@babel/eslint-parser": "^7.12.16",
    "@storybook/addon-actions": "^6.5.0-alpha.61",
    "@storybook/addon-essentials": "^6.5.0-alpha.61",
    "@storybook/addon-links": "^6.5.0-alpha.61",
    "@storybook/vue": "^6.5.0-alpha.61",
    "@vue/cli-plugin-babel": "~5.0.0",
    "@vue/cli-plugin-eslint": "~5.0.0",
    "@vue/cli-plugin-pwa": "~5.0.0",
    "@vue/cli-plugin-router": "~5.0.0",
    "@vue/cli-plugin-unit-jest": "~5.0.0",
    "@vue/cli-plugin-vuex": "~5.0.0",
    "@vue/cli-service": "~5.0.0",
    "@vue/eslint-config-prettier": "^6.0.0",
    "@vue/test-utils": "^2.0.0-0",
    "babel-eslint": "^10.1.0",
    "babel-loader": "^8.2.3",
    "compression-webpack-plugin": "^6.1.1",
    "eslint": "^7.32.0",
    "eslint-config-prettier": "^8.4.0",
    "eslint-import-resolver-alias": "^1.1.2",
    "eslint-plugin-import": "^2.25.4",
    "eslint-plugin-prettier": "^4.0.0",
    "eslint-plugin-storybook": "^0.5.8",
    "eslint-plugin-vue": "^8.5.0",
    "jest-canvas-mock": "^2.3.1",
    "jsdoc": "^3.6.10",
    "jsdoc-vuejs": "^4.0.0",
    "lint-staged": "^9.5.0",
    "lodash.clonedeep": "^4.5.0",
    "prettier": "^2.5.1",
    "sass": "^1.49.8",
    "sass-loader": "^12.0.0",
    "storybook-vue-router": "^1.0.7",
    "vue": "^3.2.31",
    "vue-loader": "^17.0.0",
    "vue-svg-loader": "^0.17.0-beta.2"
  },
  "gitHooks": {
    "pre-commit": "lint-staged"
  },
  "lint-staged": {
    "*.{js,jsx,vue}": [
      "vue-cli-service lint",
      "git add"
    ]
  }
}

@prathamesh-gharat
Copy link

prathamesh-gharat commented Apr 11, 2022

This is my package.json for reference.

"devDependencies": {
    "@babel/core": "^7.17.9",
    "@babel/plugin-proposal-class-properties": "^7.16.7",
    "@babel/plugin-proposal-decorators": "^7.17.9",
    "@babel/plugin-proposal-export-default-from": "^7.16.7",
    "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
    "@babel/plugin-proposal-object-rest-spread": "^7.17.3",
    "@babel/plugin-proposal-optional-chaining": "^7.16.7",
    "@babel/plugin-proposal-private-methods": "^7.16.11",
    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
    "@babel/plugin-transform-arrow-functions": "^7.16.7",
    "@babel/plugin-transform-block-scoping": "^7.16.7",
    "@babel/plugin-transform-classes": "^7.16.7",
    "@babel/plugin-transform-destructuring": "^7.17.7",
    "@babel/plugin-transform-for-of": "^7.16.7",
    "@babel/plugin-transform-parameters": "^7.16.7",
    "@babel/plugin-transform-shorthand-properties": "^7.16.7",
    "@babel/plugin-transform-spread": "^7.16.7",
    "@babel/preset-env": "^7.16.11",
    "@babel/preset-typescript": "^7.16.7",
    "@storybook/addon-actions": "^6.5.0-alpha.60",
    "@storybook/addon-essentials": "^6.5.0-alpha.60",
    "@storybook/addon-links": "^6.5.0-alpha.60",
    "@storybook/vue3": "^6.5.0-alpha.60",
    "babel-loader": "^8.2.4",
    "babel-plugin-macros": "^3.1.0",
    "babel-plugin-polyfill-corejs3": "^0.5.2",
    "core-js": "^3.21.1",
    "vue": "^3.2.31"
  },
  "dependencies": {}

Edit: I installed it using npx sb init earlier today. Then followed by npx sb@next upgrade --prerelease and npm i -D vue@latest
I had also installed and then later removed vue-loader@next.

Screenshot: https://i.imgur.com/jSbrxLl.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests