Coder Social home page Coder Social logo

Comments (15)

weiweipeng avatar weiweipeng commented on June 6, 2024 1

希望能升级啊

from dva.

geekact avatar geekact commented on June 6, 2024

一方面可以在package.json中强制指定immer

{
  "dependencies": {
    "dva-immer": "^1.0.0"
  },
  "resolutions": {
    "dva-immer/immer": "^9.0.6"
  }
}

另一方面,考虑弃坑 #2490

from dva.

weiweipeng avatar weiweipeng commented on June 6, 2024

我试过了,这个方法不行呢!我用的是umi框架,里面直接内嵌dva,坑死

from dva.

geekact avatar geekact commented on June 6, 2024

如果直接依赖不是dva-immer,则需要一层层传递下去,

{
  "你的依赖/中间依赖a/b/c/immer": "^9.0.6"
}

中间依赖需要你自己去yarn.lock文件中找

from dva.

weiweipeng avatar weiweipeng commented on June 6, 2024

试过了大佬的方法,.lock文件版本已经到9.0.6,但是node_modules immer版本还是8.0.4

from dva.

geekact avatar geekact commented on June 6, 2024

试过了大佬的方法,.lock文件版本已经到9.0.6,但是node_modules immer版本还是8.0.4

不,你要看目录 node_modules/dva-immer/node_modules/immer 里的版本号,其实是已经成功切换到指定版本了。

{
  "resolutions": {
    "umi-plugin-react/umi-plugin-dva/dva-immer/immer": "^9.0.6"
  }
}

from dva.

weiweipeng avatar weiweipeng commented on June 6, 2024

试过了大佬的方法,.lock文件版本已经到9.0.6,但是node_modules immer版本还是8.0.4

不,你要看目录 node_modules/dva-immer/node_modules/immer 里的版本号,其实是已经成功切换到指定版本了。

{
  "resolutions": {
    "umi-plugin-react/umi-plugin-dva/dva-immer/immer": "^9.0.6"
  }
}

一切都是以node_modules/dva-immer/node_modules/immer版本号为主,lock文件夹里面的版本号不能作为依据?

from dva.

geekact avatar geekact commented on June 6, 2024

你可能不太清楚require的规则 http://nodejs.cn/api/modules/loading_from_node_modules_folders.html

然后就是umi项目里,依赖到immer的地方太多,各个immer版本都有,所以lock文件里应该是有很多immer的并且都不兼容

yarn why immer

from dva.

weiweipeng avatar weiweipeng commented on June 6, 2024

你可能不太清楚require的规则 http://nodejs.cn/api/modules/loading_from_node_modules_folders.html

然后就是umi项目里,依赖到immer的地方太多,各个immer版本都有,所以lock文件里应该是有很多immer的并且都不兼容

yarn why immer

嗯嗯,是的,dva-immer里面的immer插件还是不行,那边依赖的8.0.4版本直接按需下载在dva-immer的node_modules,好像没办法强行修改它的依赖

from dva.

geekact avatar geekact commented on June 6, 2024

你可能不太清楚require的规则 http://nodejs.cn/api/modules/loading_from_node_modules_folders.html
然后就是umi项目里,依赖到immer的地方太多,各个immer版本都有,所以lock文件里应该是有很多immer的并且都不兼容

yarn why immer

嗯嗯,是的,dva-immer里面的immer插件还是不行,那边依赖的8.0.4版本直接按需下载在dva-immer的node_modules,好像没办法强行修改它的依赖

还有一个办法就是把所有用到immer的库都加入到resolutions强行升级,这样肯定只有一个immer。
另外考虑弃坑

from dva.

weiweipeng avatar weiweipeng commented on June 6, 2024

你可能不太清楚require的规则 http://nodejs.cn/api/modules/loading_from_node_modules_folders.html
然后就是umi项目里,依赖到immer的地方太多,各个immer版本都有,所以lock文件里应该是有很多immer的并且都不兼容

yarn why immer

嗯嗯,是的,dva-immer里面的immer插件还是不行,那边依赖的8.0.4版本直接按需下载在dva-immer的node_modules,好像没办法强行修改它的依赖

还有一个办法就是把所有用到immer的库都加入到resolutions强行升级,这样肯定只有一个immer。 另外考虑弃坑
"resolutions": {
"plugin-dva/dva-immer/immer": "^9.0.6",
"immer": "^9.0.6",
"isomorphic-fetch/node-fetch": "^3.1.1",
"node-fetch": "^3.1.1"
},
试过了,还是不行,内部嵌入依赖好像没办法强行修改,弃坑是来不及了,项目都要上架了,太难了,这个坑挖的,umi框架能不能在运行时去掉,只安装node相关的?

from dva.

geekact avatar geekact commented on June 6, 2024

你这个resolutions写的。。。plugin-dva是你自己装的吗?
我昨天创建的umi项目,按照这个配置,可以把所有immer统一到9.0.6

{
  "resolutions": {
    "umi-plugin-react/umi-plugin-dva/dva-immer/immer": "^9.0.6",
    "umi/umi-ui/react-dev-utils/immer": "^9.0.6",
    "umi-plugin-react/umi-plugin-ui/immer": "^9.0.6",
    "umi/umi-build-dev/umi-plugin-ui/immer": "^9.0.6"
  }
}

然后lock文件会呈现出下面的状态

# yarn.lock


[email protected], immer@^2.1.1, immer@^5.0.0, immer@^9.0.6:
  version "9.0.14"
  resolved "https://registry.yarnpkg.com/immer/-/immer-9.0.14.tgz#e05b83b63999d26382bb71676c9d827831248a48"
  integrity sha512-ubBeqQutOSLIFCUBN03jGeOS6a3DoYlSYwYJTa+gSKEZKU5redJIqkIdZ3JVv/4RZpfcXdAWH5zCNLWPRv2WDw==

如果还不行,说明你的其它插件里也带了immer,需要你在yarn.lock里找到并写进resolutions。记住,开头必须是你自己装的插件

from dva.

weiweipeng avatar weiweipeng commented on June 6, 2024

谢谢大佬,之前大概是用npm,改成了yarn就好了

from dva.

geekact avatar geekact commented on June 6, 2024

新项目考虑换成这个库,带你飞:https://github.com/foca-js/foca

from dva.

weiweipeng avatar weiweipeng commented on June 6, 2024

新项目考虑换成这个库,带你飞:https://github.com/foca-js/foca

可以的,下次项目试试大佬的,以后再也不用这个库了,太坑了!

from dva.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.