简体   繁体   English

Webpack在Linux上找不到lodash子模块,但在macOS上可以正常工作

[英]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/snakecaselodash/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.jssnakeCase.js ,但是您尝试分别导入不存在的clonedeepsnakecase 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.

相关问题 webpack:在MacOS上很好,linux上的加载程序错误 - webpack: fine on MacOS, loader errors on linux 无法使用绝对文件路径导入 nodejs 模块(流星,linux。在 Windows 上工作正常) - Can't import nodejs module using absolute file path (meteor, linux. Works fine on Windows) Heroku 上的 Angular 构建失败找不到模块,但在本地运行良好 - Angular build failed on heroku can't find module but works fine on local NodeJS脚本在macOS上可以正常运行,但在Windows上不能正常运行 - NodeJS script works fine on macOS but not on Windows 在节点 V14 中从 std/esm 迁移到 esm 支持 - 找不到命名导入 - 与 std/esm 一起工作正常 - Migrating from std/esm to esm support in node V14 - can't find named import - works fine with std/esm Webpack:找不到bundle.js - Webpack: can't find bundle.js WebPack-错误找不到.src文件夹 - WebPack - Error can't find .src folder Express找不到Webpack捆绑包 - Express can't find Webpack bundle Nodejs Shell脚本在Linux上运行良好,但在Windows中运行不正常。 为什么不执行多个命令 - Nodejs shell script works fine in linux but not in Windows. Why won't it execute more than one command Webpack 仅在云构建期间无法解析 url,本地工作正常 - Webpack can't resolve url only during cloud build, working fine locally
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM