gpt4 book ai didi

javascript - webpack:在 MacOS 上正常,在 linux 上加载程序错误

转载 作者:数据小太阳 更新时间:2023-10-29 05:18:46 34 4
gpt4 key购买 nike

我有一些 webpack/raw-loader/sass-sync-loader 问题。在我的本地机器上,一切运行良好。然而,在我的 linux CI 服务器上,webpack 失败了。

有人可以指导我如何开始诊断发生了什么吗?我不太确定从哪里开始。

这是 linux 上的 webpack 输出:

Hash: 314a28b414704badd07b
Version: webpack 1.4.15
Time: 7350ms
Asset Size Chunks Chunk Names
main.js 1648360 0 [emitted] main
main.css 138069 0 [emitted] main
+ 595 hidden modules

ERROR in ./~/raw-loader!./~/autoprefixer-loader
!./node_loaders/sass-sync-loader.js?sync&outputStyle=compact&
includePaths[]=/home/u65/src/repo/desktop-prototype/.generated/design-assets&
includePaths[]=/home/u65/src/repo/desktop-prototype/.generated/design-properties&
includePaths[]=/home/u65/src/repo/desktop-prototype/app!./app/index.scss
Module build failed:
@ ./app/index.scss 4:14-564

<SNIP>

ERROR in ./app/index.scss Module build failed:
Error: Didn't get a result from child compiler
at Object.<anonymous> (/home/u65/src/repo/desktop-prototype/
node_modules/extract-text-webpack-plugin/loader.js:90:22)
at Tapable.<anonymous> (/home/u65/src/repo/desktop-prototype/node_modules/webpack/lib/Compiler.js:210:10) at /home/u65/src/repo/desktop-prototype/node_modules/webpack/lib/Compiler.js:397:12 at Tapable.next (/home/u65/src/repo/desktop-prototype/node_modules/webpack/node_modules/tapable/lib/Tapable.js:69:11) at Object.<anonymous> (/home/u65/src/repo/desktop-prototype/node_modules/extract-text-webpack-plugin/loader.js:77:5) at Tapable.next (/home/u65/src/repo/desktop-prototype/node_modules/webpack/node_modules/tapable/lib/Tapable.js:71:37) at CachePlugin.<anonymous> (/home/u65/src/repo/desktop-prototype/node_modules/webpack/lib/CachePlugin.js:40:4) at Tapable.applyPluginsAsync (/home/u65/src/repo/desktop-prototype/node_modules/webpack/node_modules/tapable/lib/Tapable.js:73:13) at Tapable.<anonymous> (/home/u65/src/repo/desktop-prototype/node_modules/webpack/lib/Compiler.js:394:9) at Tapable.<anonymous> (/home/u65/src/repo/desktop-prototype/node_modules/webpack/lib/Compilation.js:534:13)

<SNIP>

ERROR in ./~/raw-loader!./~/autoprefixer-loader!
./node_loaders/sass-sync-loader.js?sync&outputStyle=compact&includePaths[]=
/home/u65/src/repo/desktop-prototype/.generated/designassets&
includePaths[]=/home/u65/src/repo/desktop-prototype/.generated/design-
properties&includePaths[]=/home/u65/src/repo/desktop-prototype/
app!./app/index.scss
Module build failed: Child extract-text-webpack-plugin:
+ 1 hidden modules
Child extract-text-webpack-plugin:
+ 1 hidden modules

最佳答案

正如@Richard_Boardman 所指出的,Mac 不区分大小写,但 Linux 区分大小写。因此,大小写的任何拼写错误在您的 Mac 开发环境中都可以正常工作,但在部署时会失败。

您可以强制 Webpack 在开发服务器和构建中更精确地匹配其文件名和路径 - 因此拼写错误仍然会在您的开发箱上失败,而不是在服务器上 - 通过使用像 case-sensitive-paths-webpack-plugin 这样的 Webpack 插件.

安装好后,您可以编写一些测试,例如:

describe("Case-Sensitive Paths Plugin", () => {
it('shouldn\'t interfere with correctly-spelled imports', () => {
const getUser1 = require('../src/utils/api');
expect(getUser1).toBeDefined();
});

it('should cause mistakes in filename case to fail import', () => {
expect(() => {const getUser2 = require('../src/utils/API');}).toThrow();
});

it('should cause mistakes in path case to fail import', () => {
expect(() => {const getUser3 = require('../src/Utils/api');}).toThrow();
});
});

关于javascript - webpack:在 MacOS 上正常,在 linux 上加载程序错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28789050/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com