[英]Webpack can't find lodash submodules on linux but works fine on macOS
I have realized that my electron application does not want to build properly on linux, whereas on macOS it works fine. 我已经意识到我的电子应用程序不想在Linux上正确构建,而在macOS上却可以正常工作。 I'm not quite sure why. 我不太确定为什么。
So on macOS this works fine 所以在macOS上可以正常工作
let _snakecase = require('lodash/snakecase')
let _cloneDeep = require('lodash/clonedeep')
let _filter = require('lodash/filter')
On linux this throws errors that it can't find the dependencies lodash/snakecase
and lodash/clonedeep
. 在Linux上,这会引发错误,导致找不到依赖项lodash/snakecase
和lodash/clonedeep
。 Strangely enough it can find lodash/filter
. 奇怪的是,它可以找到lodash/filter
。 I can only get it to work if import it like so: 如果像这样导入它,我只能使其工作:
import {snakecase as _snakecase} from 'lodash'
import {clonedeep as _cloneDeep} from 'lodash'
import {filter as _filter} from 'lodash'
But my question is why can I require('lodash/filter')
but not require('lodash/snakecase')
? 但是我的问题是为什么我可以require('lodash/filter')
但不能require('lodash/snakecase')
? I don't even know where to start looking to debug this. 我什至不知道从哪里开始寻找调试的方法。
The exact error when I try to require lodash/snakecase
: 当我尝试要求lodash/snakecase
时的确切错误:
This dependency was not found:
* lodash/snakecase in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./src/views/modals/ChannelModal.vue
The file system on macOS is case- in sensitive by default, which means when you ask for a file that doesn't exist, let's say file.js
, it will gladly give you FILE.js
if that one exists. 在Mac OS文件系统是敏感的,默认情况下,当你问对不存在的文件,让我们说,这意味着区分file.js
,它会很乐意给你FILE.js
如果一个存在。 On a case-sensitive file system, it would just tell you that file.js
doesn't exist and result in an error. 在区分大小写的文件系统上,它只会告诉您file.js
不存在并导致错误。 The file systems on Linux are case-sensitive. Linux上的文件系统区分大小写。
The files you are looking for are cloneDeep.js
and snakeCase.js
, but you're trying to import clonedeep
and snakecase
respectively, which do not exist. 您要查找的文件是cloneDeep.js
和snakeCase.js
,但是您尝试分别导入不存在的clonedeep
和snakecase
。 lodash/filter
works because filter.js
actually exists. lodash/filter
之所以filter.js
是因为filter.js
实际上存在。
The correct imports would be: 正确的进口是:
let _snakecase = require('lodash/snakeCase')
let _cloneDeep = require('lodash/cloneDeep')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.