Webpack无法在Linux上找到lodash子模块,但在macOS上运行正常

时间:2017-10-23 10:14:58

标签: node.js webpack ecmascript-6 electron babel

我已经意识到我的电子应用程序不想在linux上正确构建,而在macOS上它工作正常。我不太清楚为什么。

所以在macOS上这很好用

let _snakecase = require('lodash/snakecase')
let _cloneDeep = require('lodash/clonedeep')
let _filter = require('lodash/filter')

在Linux上,这会引发错误,无法找到依赖项lodash/snakecaselodash/clonedeep。奇怪的是,可以找到lodash/filter。如果像这样导入它,我只能让它工作:

import {snakecase as _snakecase} from 'lodash'
import {clonedeep as _cloneDeep} from 'lodash'
import {filter as _filter} from 'lodash'

但我的问题是为什么require('lodash/filter')而不是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

1 个答案:

答案 0 :(得分:1)

默认情况下,macOS上的文件系统是 敏感,这意味着当您要求存在不存在的文件时,请说file.js如果存在FILE.js,它会很乐意给你file.js。在区分大小写的文件系统上,它只会告诉您clonedeep不存在并导致错误。 Linux上的文件系统区分大小写。

您要查找的文件是cloneDeep.jssnakeCase.js,但您分别尝试导入snakecaselodash/filter,这些文件不存在。 let _snakecase = require('lodash/snakeCase') let _cloneDeep = require('lodash/cloneDeep') 有效,因为filter.js确实存在。

正确的导入是:

import pygame, time, math, os
from pygame.locals import *
from sys import exit

pygame.init()        
pygame.mouse.set_visible(0)
pygame.mouse.set_pos(0, 0)
screen = pygame.display.set_mode((800, 480))