首页 > 其他分享 >pinia: Cannot read properties of undefined (reading '_s')

pinia: Cannot read properties of undefined (reading '_s')

时间:2023-10-24 21:57:22浏览次数:36  
标签:undefined read Cannot 报错 pinia pnpm reading properties

使用 Vue3 + Pinia + PNPM + Vite 开发一个前端项目时,运行preview,报错:

pinia Cannot read properties of undefined (reading '_s')

报错的代码是压缩后的:

function we(e, t, n) {
  let s, c;
  const u = typeof t == "function";
  typeof e == "string" ? ((s = e), (c = u ? n : t)) : ((c = e), (s = e.id));
  function a(o, h) {
    const f = ie();
    return (
      (o = o || (f ? ue(be, null) : null)),
      o && F(o),
      (o = H),
      o._s.has(s) || (u ? V(s, t, c, o) : ve(s, c, o)), // 报错位置
      o._s.get(s)
    );
  }
  return (a.$id = s), a;
}

大意像是读取一个 store的名称失败导致。而我确认这个 store 已经被注册(defineStore)了。
翻阅 pinia 源码,定位到位置:https://github.com/vuejs/pinia/blob/5c94d26e11f8d2ed0e01d5a615f8e014d799b4a0/packages/pinia/src/store.ts#L895-L966 ,不过依然不明确问题原因。

突然灵感乍现,有新发现,我这个工程是 pnpm workspace, 两个包都依赖了 pinia,但版本不一致了。统一版本后再 build,问题解决。

那么,怎么保证不同的包的相同依赖版本一致呢?pnpm 给出了方案:https://pnpm.io/package_json#pnpmoverrides

标签:undefined,read,Cannot,报错,pinia,pnpm,reading,properties
From: https://www.cnblogs.com/duxing/p/17785814.html

相关文章

  • c: thread in Ubuntu 22.04
     /***@filehelloworld.c*@authoryourname([email protected])*@briefthread*@version0.1*@date2023-10-24*ide:vscodec11,c17Ubuntu22.04*@copyrightCopyright(c)2023站在巨人的肩膀上StandingontheShouldersofGiants2023**......
  • Proj CDeepFuzz Paper Reading: POLYCRUISE: A Cross-Language Dynamic Information F
    Abstract本文:PolyCruiseMethod:跨编程语言的holisticdynamicinformationflowanalysis(DIFA)usealightlanguage-specificanalysis和language-agnosticonlinedataflowanalysis来计算symbolicdependencies实验:数据集:PolyBench,包含小中大三种等级的benchmarks效......
  • EasyExcel读取所有sheet(doReadAll)报BatchUpdateException: Duplicate entry
    报错截图  原因:监听器保存数据时,但是没有重置缓存数据,导致读取第二个sheet的时候,缓存里存的数据还包含上一个或多个sheet的数据。每个sheet读取完毕后调用一次doAfterAllAnalysed。在doAfterAllAnalysed方法调用批量插入后,需要清除缓存数据cacheDataList=ListUtils.newA......
  • Java基础 read (char[] buffer) 底层原理
    FileReaderfr=newFileReader("E:\\Java基础资料\\a.txt");char[]chars=newchar[2];while(true){intlen=fr.read(chars);if(len==-1)break;System.out.print(newString(chars,0,len));}fr.close(); read(char[] buffer)......
  • centos 6.10 安装 readline 6.2.0
    centos6.10安装readline6.2.0下载地址解压文件cdreadline-6.2./configure-prefix/usr/local/readline-6.2make&&makeinstall安装完成......
  • 启动Nginx报错:error while loading shared libraries: libpcre.so.0: cannot open sha
    1.现象:输入:/usr/local/nginx/sbin/nginx报错:/usr/local/nginx/sbin/nginx:errorwhileloadingsharedlibraries:libprofiler.so.0:cannotopensharedobjectfile:Nosuchfileordirectory2.错误原因:缺少libpcre.so.0,3.进一步查看:输入:ldd$(which/usr/......
  • 一键解决TypeError: Descriptors cannot not be created directly.
    TypeError:Descriptorscannotnotbecreateddirectly.文章目录问题描述解决思路解决方法问题描述TypeError:Descriptorscannotnotbecreateddirectly.解决思路这个错误提示是关于Protobuf的,可能是因为你的代码中使用了过时的Protobuf版本导致的。下滑查看解决方法解......
  • c: thread in Ubuntu
     /***@filehelloworld.c*@authoryourname(geovindu)*@brief*ide:vscodec11,c17*@version0.1*@date2023-10-21**@copyrightCopyright(c)2023站在巨人的肩膀上StandingontheShouldersofGiants**/#include<stdlib.h>#includ......
  • cadquery创建螺纹thread
    参考来源:https://github.com/CadQuery/cadquery/issues/407importmathimportcadqueryascqdefprofile(base,pitch,h,extra=True):"""pitch螺距Createsatrapezoidalwireforthecrosssectionofthethread.Ifthecrosssectiono......
  • 探索Java中神奇的ThreadLocal:为什么它是多线程编程的重要工具?
    (文章目录)......