-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Cannot resolve dependency 'snabbdom/init' #723
Comments
It should be |
I also encountered the same problem. The version of snabbdom is 1.0.1 |
I don't see anything wrong with the package. Could you provide a reproduction, please? Or, at least the output of the parcel command. |
this is my package.json:
this is my entry file
**01-demo.js **
parcel build error
|
Thank you. It may be that that version of parcel does not support the exports field. |
Same issue on codesandbox (which also uses parcel): https://codesandbox.io/s/crazy-spence-xq8vm?file=/src/index.js Was able to use 0.7.4 with no issue. |
There is also an error in Webpack 4.43.0: code ELIFECYCLE English is not my native language; please excuse typing errors. |
Did anyone try using parcel v2? |
yarn:1.22.4 parcel:2.0.0-beta.1:
|
Hi, I encountered the same problem too. It seems like node is not able to register the module itself.
The same problem occurs when I was trying to setup client-side code in webpack v4.43.0:
|
Until your resolver supports the exports field, a workaround could be to prefix the import path with |
@f43310 You can try installing version 0.7.4; |
I would not recommend this. v1 has some bug fixes and performance improvements and it is ES modules. |
snabbdom版本导致运行错误问题解决方法如果遇到下面的错误,检查 Snabbdom 的版本,Snabbdom 在 2020年6月18日更新到 v1.0.1 版本。 Cannot resolve dependency 'snabbdom/init' 案例中用的版本是 v0.7.4 版本,如果你安装的是 Snabbdom@v1.0.1 的版本会出现上面的错误。 解决方法:安装 Snabbdom@v0.7.4版本 原因:v1.0.1 版本相对于 v0.7.4 版本的变化,去除了 snabbdom.ts 模块,新增了 init.ts 模块,如果使用 v1.0.1 版本的话导入 h、init 函数,文档中写的是如下的方式: import { init } from 'snabbdom/init'
import { h } from 'snabbdom/h' // helper function for creating vnodes 但是我们案例中改成这样的导入方式,问题依然无法解决。 因为模块路径并不是 snabbdom/int,这个路径是作者在 package.json 中的 exports 字段设置的,而我们使用的打包工具不支持 exports 这个字段,webpack 4 也不支持,webpack 5 beta 支持该字段。该字段在导入 snabbdom/init 的时候会补全路径成 snabbdom/build/package/init.js。 "exports": {
"./init": "./build/package/init.js",
"./h": "./build/package/h.js",
"./helpers/attachto": "./build/package/helpers/attachto.js",
"./hooks": "./build/package/hooks.js",
"./htmldomapi": "./build/package/htmldomapi.js",
"./is": "./build/package/is.js",
"./jsx": "./build/package/jsx.js",
"./modules/attributes": "./build/package/modules/attributes.js",
"./modules/class": "./build/package/modules/class.js",
"./modules/dataset": "./build/package/modules/dataset.js",
"./modules/eventlisteners": "./build/package/modules/eventlisteners.js",
"./modules/hero": "./build/package/modules/hero.js",
"./modules/module": "./build/package/modules/module.js",
"./modules/props": "./build/package/modules/props.js",
"./modules/style": "./build/package/modules/style.js",
"./thunk": "./build/package/thunk.js",
"./tovnode": "./build/package/tovnode.js",
"./vnode": "./build/package/vnode.js"
} 所以如果使用 Snabbdom@v1.0.1 的话,导入 init、h,以及模块只要把把路径补全即可。 import { h } from 'snabbdom/build/package/h'
import { init } from 'snabbdom/build/package/init'
import { classModule } from 'snabbdom/build/package/modules/class' 作者关于该问题的回复 |
import { init } from 'snabbdom/init'
node log file:
package.json
js file:
import { init } from 'snabbdom/init'
The text was updated successfully, but these errors were encountered: