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

Not able to use pinia: No matching export in "node_modules/pinia/node_modules/vue-demi/lib/index.mjs" for import "hasInjectionContext" #2210

Closed
shree-c opened this issue May 17, 2023 · 15 comments

Comments

@shree-c
Copy link

shree-c commented May 17, 2023

Reproduction

https://github.com/shree-c/mock_two_test_pinia

Steps to reproduce the bug

Screenshot from 2023-05-17 15-26-02
Screenshot from 2023-05-17 15-29-38

Expected behavior

I am doing basic activity such as creating a store and importing it into a component.

Actual behavior

Vite not able to build both for dev and prod.
I am getting the following error on vite terminal:
No matching export in "node_modules/pinia/node_modules/vue-demi/lib/index.mjs" for import "hasInjectionContext"

Additional information

No response

@posva
Copy link
Member

posva commented May 17, 2023

You need to update vue to 3.3. I should have set the peer dep...

@posva posva closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2023
@shunyue1320
Copy link

"hasInjectionContext" is not exported by "node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/vue-demi/lib/index.mjs", imported by "node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/pinia/dist/pinia.mjs".

image

@temofart
Copy link

@shree-c @shunyue1320 hey guys, any updated? i have the same issue while migrating from vue-cli to vite

@lautaandreani
Copy link

For me, work update to vue 3.3.4

"pinia": "^2.1.3",
"vue": "^3.3.4",

@MickeyMouse623
Copy link

image 还是不行

@MickeyMouse623
Copy link

image 这个版本配置正常运行

@BeidouGoan
Copy link

image 这个版本配置正常运行
只能说与[email protected][email protected]无缘

@outNapGnaw
Copy link

image
依然存在报错

@MikeMitterer
Copy link

MikeMitterer commented Oct 23, 2023

Argg.... had to downgrade to 2.0.35 because of this bug. @posva There are a lot of 2.7 installations in the field. Upgrading to vue 3.x is very often not possible. So to others with the same problem: Vue 2.7 only works with Pinia 2.0.35 (and below???, not tested)

@temofart
Copy link

I just upgraded vue and pinia both to the latest versions and everything is ok

Copy link
Member

posva commented Oct 23, 2023

For vue 2 update vue-demi so it has the correct exports

@869288142
Copy link

image 这个版本配置正常运行
只能说与[email protected][email protected]无缘

if you use uni-app, it's inner vue version is 3.2.47. we must be use pinia 2.0.x

@chengazhen
Copy link

uniapp 使用pinna必须使用固定的版本

@JasonCareter
Copy link

少了一行导出而已,加上就完了,yarn install后执行一行命令把代码添加进index.mjs就行了
echo 'export function hasInjectionContext() {return !!Vue.getCurrentInstance()}' >> ./node_modules/vue-demi/lib/index.mjs

@jaythomas
Copy link

The fix for a fresh vite + vue 2.7 app was to downgrade pinia from 2.1.7 to 2.0.x. Seems there was some regression in the dependency chain. Hope this helps the next person that sees this GitHub issue in the search results trying to troubleshoot this problem and hopefully this issue will be resolved in a future version of pinia.

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