webpack 挂在 "95% emit" / "95% emitting"
webpack hangs at on "95% emit" / "95% emitting"
This is my production webpack config。标题中的两个引号分别指的是 webpack2 和 webpack。两者都因类似的错误而挂起。
这是我触发构建的命令
set NODE_ENV=production && webpack --config config/webpack.config.prod.js --progress --display-error-details
我错过了什么?
这是 运行 npm run pack
之后的输出,它与我的生产 webpack 构建相关:
$ npm run pack
> somedir@ pack C:\somedir
> set NODE_ENV=production && webpack --config config/webpack.config.prod.js --progress --display-error-details
95% emitting
所以我想通了。原来我包括了 reserved characters in my output path. I've since opened an issue on github.
When using an invalid or reserved character in the output.path webpack
will hang with no output. Running with the --progress flag will show
that it's hanging on 95% emit(ting) (suffix depending on webpack
version).
在我的例子中,我尝试使用 Angular 4、Webpack 3、AOT 和延迟加载。
使用 @ngtools/webpack
和 AotPlugin 使其冻结在 95%。
修复的是:
1).用 npm install node-sass --no-bin-links
安装 node-sass
,因为它不是用 sass-loader
自动安装的。
2).为 SCSS/CSS 文件添加这些加载器(甚至在节点模块内):
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
{
test: /\.scss$/,
use: [
'raw-loader',
'sass-loader'
]
}
npm rebuild node-sass
我解决了。
我使用 laravel-mix 作为 独立 。
这是我的配置:
let mix = require('laravel-mix');
mix.setPublicPath('./')
.js('resources/js/app.js', 'js')
.sass('resources/sass/app.scss', 'css');
这对我有用。
在我的例子中(Windows 环境和 laravel-混合)路径中没有任何不正确的字符,因为即使是简单的配置也不起作用。这只是 webpack (webpack@3.12.0) 做了他自己的一些愚蠢的事情,问题已经使用 publicPath
选项解决了,如下所示:
mix.options({
publicPath: ('./')
});
allows you to specify the base path for all the assets within your application
或者您可以使用:
mix.setPublicPath('./');
如果导入无效,也会发生此错误。
从其他未编译的文件导入引用。
我通过升级到 webpack@4.41.2
来修复
运行 ng build
和 node --inspect node_modules/webpack/bin/webpack.js
应该给出问题路径的输出
我在复制 index.html 时点击错误(从 angular 文件夹中剪切该文件)。将它们复制回去后,问题就消失了。
我在设置项目时在 Angular 中遇到了同样的问题。问题是我错误地将 index.html 文件放在了 ./src
文件夹之外。
如果您使用 indexTransform
属性 并且函数抛出错误,也会发生这种情况。要处理这个问题,您可以将函数包装在 try/catch;
中
module.exports = (targetOptions, indexHtml) => {
try {
...
} catch (error) {
console.error(error)
process.exit(1) // Kills webpack
}
}
在我的例子中,它与 output.path 中定义的目录有关。删除它的内容后(不同的文件夹和不同的包)一切都恢复正常了。
我遇到了同样的问题。我在 <div>
.
上遗漏了结束语 >
Webpack (mix) 会挂起,而不仅仅是编译失败,我不确定为什么。
希望这可以为某人节省几个小时的误入歧途。
This is my production webpack config。标题中的两个引号分别指的是 webpack2 和 webpack。两者都因类似的错误而挂起。
这是我触发构建的命令
set NODE_ENV=production && webpack --config config/webpack.config.prod.js --progress --display-error-details
我错过了什么?
这是 运行 npm run pack
之后的输出,它与我的生产 webpack 构建相关:
$ npm run pack
> somedir@ pack C:\somedir
> set NODE_ENV=production && webpack --config config/webpack.config.prod.js --progress --display-error-details
95% emitting
所以我想通了。原来我包括了 reserved characters in my output path. I've since opened an issue on github.
When using an invalid or reserved character in the output.path webpack will hang with no output. Running with the --progress flag will show that it's hanging on 95% emit(ting) (suffix depending on webpack version).
在我的例子中,我尝试使用 Angular 4、Webpack 3、AOT 和延迟加载。
使用 @ngtools/webpack
和 AotPlugin 使其冻结在 95%。
修复的是:
1).用 npm install node-sass --no-bin-links
安装 node-sass
,因为它不是用 sass-loader
自动安装的。
2).为 SCSS/CSS 文件添加这些加载器(甚至在节点模块内):
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
{
test: /\.scss$/,
use: [
'raw-loader',
'sass-loader'
]
}
npm rebuild node-sass
我解决了。
我使用 laravel-mix 作为 独立 。 这是我的配置:
let mix = require('laravel-mix');
mix.setPublicPath('./')
.js('resources/js/app.js', 'js')
.sass('resources/sass/app.scss', 'css');
这对我有用。
在我的例子中(Windows 环境和 laravel-混合)路径中没有任何不正确的字符,因为即使是简单的配置也不起作用。这只是 webpack (webpack@3.12.0) 做了他自己的一些愚蠢的事情,问题已经使用 publicPath
选项解决了,如下所示:
mix.options({
publicPath: ('./')
});
allows you to specify the base path for all the assets within your application
或者您可以使用:
mix.setPublicPath('./');
如果导入无效,也会发生此错误。 从其他未编译的文件导入引用。
我通过升级到 webpack@4.41.2
来修复
运行 ng build
和 node --inspect node_modules/webpack/bin/webpack.js
应该给出问题路径的输出
我在复制 index.html 时点击错误(从 angular 文件夹中剪切该文件)。将它们复制回去后,问题就消失了。
我在设置项目时在 Angular 中遇到了同样的问题。问题是我错误地将 index.html 文件放在了 ./src
文件夹之外。
如果您使用 indexTransform
属性 并且函数抛出错误,也会发生这种情况。要处理这个问题,您可以将函数包装在 try/catch;
module.exports = (targetOptions, indexHtml) => {
try {
...
} catch (error) {
console.error(error)
process.exit(1) // Kills webpack
}
}
在我的例子中,它与 output.path 中定义的目录有关。删除它的内容后(不同的文件夹和不同的包)一切都恢复正常了。
我遇到了同样的问题。我在 <div>
.
>
Webpack (mix) 会挂起,而不仅仅是编译失败,我不确定为什么。 希望这可以为某人节省几个小时的误入歧途。