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

Vite could not find @vueuse/shared if slidev/cli is install globally #410

Closed
aeudes opened this issue Nov 14, 2021 · 9 comments
Closed

Vite could not find @vueuse/shared if slidev/cli is install globally #410

aeudes opened this issue Nov 14, 2021 · 9 comments

Comments

@aeudes
Copy link
Contributor

aeudes commented Nov 14, 2021

Describe the bug
When slidev is install globally, running slidev gives the following error :

[vite] Internal server error: Failed to resolve import "@vueuse/shared" from "../../.local/lib/node_modules/@slidev/cli/node_modules/.vite/@vueuse_motion.js?v=8e598f5d". Does the file exist?
  Plugin: vite:import-analysis
  File: /home/alex/.local/lib/node_modules/@slidev/cli/node_modules/.vite/@vueuse_motion.js?v=8e598f5d
  177|
  178|  // ../../.local/lib/node_modules/@slidev/cli/node_modules/@vueuse/motion/dist/index.mjs
  179|  import { tryOnUnmounted as tryOnUnmounted2, isFunction as isFunction2 } from "@vueuse/shared";
     |                                                                                ^
  180|
  181|  // ../../.local/lib/node_modules/@slidev/cli/node_modules/framesync/dist/es/on-next-frame.mjs
      at formatError (/home/alex/.local/lib/node_modules/@slidev/cli/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:42189:46)
      at TransformContext.error (/home/alex/.local/lib/node_modules/@slidev/cli/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:42185:19)
      at normalizeUrl (/home/alex/.local/lib/node_modules/@slidev/cli/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:67284:26)
      at async TransformContext.transform (/home/alex/.local/lib/node_modules/@slidev/cli/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:67424:57)
      at async Object.transform (/home/alex/.local/lib/node_modules/@slidev/cli/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:42396:30)
      at async doTransform (/home/alex/.local/lib/node_modules/@slidev/cli/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:56801:29)

The @vueuse/shared package is install as internal dependency of @vueuse/core:

@slidev/cli/node_modules/@vueuse/core/node_modules/@vueuse/shared

It may be a duplicate of #392 .

I find the following work around, install @vueuse/shared globally

npm install -g @vueuse/shared@6.8.0 vue@3.2.21

by default npm seems to install the vue2 version of demi, so I have to add vue3 to force correct dependency... There is maybe an other way (npm/node.js newbie here...).

To Reproduce
Steps to reproduce the behavior:

  1. npm install -g @slidev/cli
  2. npm install -g @slidev/client katex (see When install @slidev/cli globally, we are forced to globally install @slidev/client and katex  #409)
  3. slidev
  4. answer yes to create slides.md
  5. answer yes to install template
  6. see slidev running
  7. open firefox to localhost:3030
  8. got the error

Desktop (please complete the following information):

  • OS: arch linux
  • Browser: firefox
  • Slidev version: 0.27.13
@TheoCUC
Copy link

TheoCUC commented Nov 20, 2021

I have this error too. And I have tried install it globally in Windows, WSL and Ubuntu , all failed.

[vite] Internal server error: Failed to resolve import "@vueuse/shared" from "../../../usr/local/lib/node_modules/@slidev/cli/node_modules/@vueuse/motion/dist/index.mjs". Does the file exist?
  Plugin: vite:import-analysis
  File: /usr/local/lib/node_modules/@slidev/cli/node_modules/@vueuse/motion/dist/index.mjs
  1  |  import { ref, set, del, unref, watch, computed, reactive, isRef } from 'vue-demi';
  2  |  import { isObject, useEventListener, noop, useIntersectionObserver, tryOnUnmounted as tryOnUnmounted$1, unrefElement, isNumber, useMediaQuery } from '@vueuse/core';
  3  |  import { tryOnUnmounted, isFunction } from '@vueuse/shared';
     |                                              ^
  4  |  import sync, { getFrameData } from 'framesync';
  5  |  import { velocityPerSecond, inertia, animate, cubicBezier, linear, easeIn, easeInOut, easeOut, circIn, circInOut, circOut, backIn, backInOut, backOut, anticipate, bounceIn, bounceInOut, bounceOut } from 'popmotion';
      at formatError (/usr/local/lib/node_modules/@slidev/cli/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:42189:46)
      at TransformContext.error (/usr/local/lib/node_modules/@slidev/cli/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:42185:19)
      at normalizeUrl (/usr/local/lib/node_modules/@slidev/cli/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:67284:26)
      at async TransformContext.transform (/usr/local/lib/node_modules/@slidev/cli/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:67424:57)
      at async Object.transform (/usr/local/lib/node_modules/@slidev/cli/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:42396:30)
      at async doTransform (/usr/local/lib/node_modules/@slidev/cli/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:56801:29)

@aeudes
Copy link
Contributor Author

aeudes commented Nov 20, 2021

By the way, I did not have this error when install globally with yarn on archlinux.

@TheoCUC
Copy link

TheoCUC commented Nov 20, 2021

Thank you for your idea, I just tested install slidev with yarn on WSL(Ubuntu) and now it works well.

@antfu
Copy link
Member

antfu commented Nov 20, 2021

I think it's because of the different hoisting strategies that your package manager is using. I can see the workaround to be as you mentioned, install the packages explictly or use local install to be more stable.

@dereknex
Copy link

same problem on mac os 12.0.1 and Apple M1.

@pytimer
Copy link

pytimer commented Dec 12, 2021

Use @aeudes method works well. Thanks.

npm install -g @vueuse/shared@6.8.0 vue@3.2.21

@NewRudy
Copy link

NewRudy commented Jan 20, 2022

thank you, npm install -g @vueuse/shared@6.8.0 vue@3.2.21 is work

@tonai
Copy link
Contributor

tonai commented May 31, 2022

This seems to be fixed.
Can you confirm ?

@aeudes
Copy link
Contributor Author

aeudes commented May 31, 2022

Yes indeed! I confirm no install problem anymore with @slidev/cli@0.31.4.

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

No branches or pull requests

7 participants