简体   繁体   English

指向分支时如何解决“找不到模块”?

[英]How do I resolve “Cannot find module” when pointing to a branch?

I hope you guys are doing well.我希望你们都做得很好。

So, the problem that I'm facing is that webpacker cannot find " react-visual-filter " module when I point to a branch.所以,我面临的问题是当我指向一个分支时,webpacker 找不到“ react-visual-filter ”模块。

Before, when everything was working fine, this package was pointing to a specific version:之前,当一切正常时,这个 package 指向一个特定的版本:

"react-visual-filter": "^1.0.9"

So I created a simple PR( #5 ) with improvement and I'm trying to test the result outside the module.所以我创建了一个简单的 PR( #5 ) 并进行了改进,并尝试在模块外测试结果。 To update the package.json file to point to my branch I used this command:要更新 package.json 文件以指向我的分支,我使用了以下命令:

yarn add https://github.com/rfdavid/react-visual-filter.git#feature/add-text-box

And the package.json file got updated to: package.json 文件更新为:

"react-visual-filter": "https://github.com/rfdavid/react-visual-filter.git#feature/add-text-box"

Ok.好的。 I think everything is fine, but when webpacker try to compile the modifications this happens:我认为一切都很好,但是当 webpacker 尝试编译修改时,会发生这种情况:

Module not found: Error: Can't resolve 'react-visual-filter' in '/path/to/app/javascript/packs'

Not found?未找到?

I tried to delete the node_modules and install everything again with yarn, but no luck.我试图删除node_modules并用 yarn 重新安装所有东西,但没有运气。

I can see that the react-visual-filter package was installed successfully inside the node_modules folder, but for some reason, it could not be found.我可以看到 react-visual-filter package 已成功安装在 node_modules 文件夹中,但由于某种原因找不到。

The funny thing is, after getting this error, if I try to update this:有趣的是,在收到此错误后,如果我尝试更新:

import VisualFilter from "react-visual-filter";

To:至:

import VisualFilter from "react-visual-filter/src";

The module is found, but I face another problem:找到了模块,但我面临另一个问题:

Module parse failed: Unexpected token (155:6)
You may need an appropriate loader to handle this file type, currently, no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

Wait, what?等等,什么? So the package exist but it can be parsed?那么 package 存在但可以解析吗?

But this file was being parsed just fine before.但是这个文件之前被解析得很好。 I'm not sure if this error is accurate.我不确定这个错误是否准确。 And I think I need to make this works this way:我认为我需要这样工作:

import VisualFilter from "react-visual-filter";

I'm lost.我迷路了。 If I return to "^1.0.9" the error disappears.如果我返回“^1.0.9”,错误就会消失。

Probably something in my PR, but I can't see what.可能在我的 PR 中有什么,但我看不到是什么。

I already updated yarn to 1.22.4 .我已经将 yarn 更新为1.22.4

Did I miss something?我错过了什么? Can anyone help me with this?谁能帮我这个?

Thank you for your time.感谢您的时间。

I set up a simple react project with create-react-app and additionally installed react-visual-filter using link to github instead of version.我使用create-react-app设置了一个简单的 react 项目,并使用指向 github 而不是版本的链接另外安装了react-visual-filter I got the same error.我得到了同样的错误。

The content of react-visual-filter was missing dist folder with necessary files such as entrypoint index.js react-visual-filter的内容缺少包含必要文件的dist文件夹,例如入口点index.js

The easiest workaround would be to unignore dist folder and push it to branch.最简单的解决方法是取消忽略dist文件夹并将其推送到分支。

If you can't do that, you might exclude src webpack.config.js and other stuff from .npmignore and build it locally after installing如果你不能这样做,你可能会从.npmignore中排除src webpack.config.js和其他东西,并在安装后在本地构建它

cd node_modules/react-visual-filter

npm run build

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我正在尝试运行 node.js,如何解决“找不到模块”错误? - I am trying to run node.js, how do I resolve "Cannot find module" error? 在汇总中如何让 --external 在命令行上直接指向要排除的模块? (没有节点解析插件) - In Rollup How do I get --external to work on the command line directly pointing to the module to exclude? (no node resolve plugin) 如何解决Ionic Uncaught Error:添加新页面时找不到模块“。”? - How can I resolve Ionic Uncaught Error: Cannot find module “.” when adding new page? 如何解决“在 PATH 错误中找不到运行时‘节点’” - How do I resolve “Cannot find runtime 'node' on PATH error” 接收找不到模块错误,我该如何解决? - Receiving cannot find module error, how do I fix it? 如何修复显示“找不到模块'mailosaur'”的错误 - How do i fix an error that reads "Cannot find module 'mailosaur'" npm测试时“找不到模块”如何解决 - How can I solve "cannot find module" when npm test 如何解决 Heroku 错误:找不到模块“puppeteer-cluster”? - How to resolve Heroku error: Cannot find module 'puppeteer-cluster'? 为什么在运行 nodejs express 服务器时出现错误:找不到模块 'html'? - Why do I get Error: Cannot find module 'html' when running nodejs express server? 导入模块时无法解析React - Cannot resolve React when importing a module
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM