【问题标题】:webpack error in missing path @ multi main缺少路径@ multi main 中的 webpack 错误
【发布时间】:2016-03-21 00:08:12
【问题描述】:

当我尝试运行我的构建时,我在 webpack 中看到了一个错误。

webpack --config conf/webpack.build.config.js --progress --colors --display-error-details --display-modules --display-reasons
Hash: e633ac8cf3ba9196f876
Version: webpack 1.12.9
Time: 312ms
                     Asset     Size  Chunks             Chunk Names
tinymce-comments-plus-bundle.js  5.88 kB       0  [emitted]  main
  [0] multi main 28 bytes {0} [built] [1 error]
  [1] ./js/tinymce-comments-plus.js 0 bytes [built] [failed]
      single entry ./js/tinymce-comments-plus.js [0] multi main
ERROR in missing path
@ multi main

当 npm 任务运行时,Options.build 为 true。我试过调整路径,但似乎找不到哪条路径是错误的。 @multi main 在哪里?

这是我的 webpack 配置。

module.exports = function( options ) {

var path = require( 'path' ),
    cssLoaders = 'style!css',
    scssLoaders = cssLoaders + '!sass',
    babelLoader = 'react-hot!babel',
    webpack = require( 'webpack' ),
    ExtractTextPlugin = require( 'extract-text-webpack-plugin' );

function extractLoaders( extract, loaders ) {
  return ExtractTextPlugin.extract( extract, loaders.substr( loaders.indexOf( '!' ) ) );
}

if ( options.build ) {
    cssLoaders = extractLoaders( 'style', cssLoaders );
    scssLoaders = extractLoaders( 'style', scssLoaders );
    babelLoader = extractLoaders( 'react-hot', babelLoader );
}


return {
    entry: [ './js/tinymce-comments-plus.js' ],
    output: {
        path: __dirname + '/../js',
        publicPath: options.build ? '/dist/' : 'http://localhost:8080/',
        filename: 'tinymce-comments-plus-bundle.js',
        // hot: true,
        // headers: { 'Access-Control-Allow-Origin': '*' }
    },
    module: {
        loaders: [
            {
                test: /\.css$/,
                loader: cssLoaders
            },
            {
                test: /\.scss$/,
                loader: scssLoaders
            },
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: babelLoader
            },
            {
                test: /\.jsx$/,
                exclude: /node_modules/,
                loader: babelLoader
            }
        ]
    },
    resolve: {
        root: [
            path.join( __dirname, '..', 'components' ),
            path.join( __dirname, '..', 'js' ),
            path.join( __dirname, '..', 'sass' ),
        ],
        extensions: [ '', '.js', '.jsx', '.sass', '.scss', '.css' ],
    },
    plugins: options.build ? [
        // build plugins
        new ExtractTextPlugin( './css/[name].css' ),
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            }
        }),
        new webpack.HotModuleReplacementPlugin()
    ] : [
        // dev plugins
        new ExtractTextPlugin( './css/[name].css' ),
        //new webpack.HotModuleReplacementPlugin()
    ]
}; }

【问题讨论】:

  • 你能提供你的应用文件结构吗? tinymce-comments-plus 的后缀是什么? .js.jsx ?
  • 感谢您的回复。 tinymce-cmets-plus.js 扩展名为 .js。对于应用程序文件结构,npm 从根目录中的 /package.json 运行脚本。 /js/ 保存 javascript 和 /conf/ 保存 webpack 配置 js。 /node_modules/ 包含所有 npm 依赖项。 /components/ 有带有 .jsx 反应组件的子目录。
  • 您找到解决方法了吗?
  • 我最终通过安装一些 NPM 包解决了这个问题。在我的特殊情况下,我相信它是 babel-loader ......但我认为这个错误可能有多种原因。
  • 我无法解决这个问题。我最终将我的项目移动到了一个更新的脚手架(newtriks react-webpack),它解决了我所有的 webpack 问题。

标签: build reactjs webpack


【解决方案1】:

我遇到了类似的问题,我建议使用 npm install -g webpack 全局安装 webpack,然后链接到全局安装 npm link webpack

另外,请确保您的扩展程序链接到 resolve.extensions

resolve: {
    extensions: ['', '.ts', '.tsx', '.js'] // <-- Had to add the .js one
}

【讨论】:

    猜你喜欢
    • 2017-02-19
    • 2016-12-22
    • 2017-10-10
    • 1970-01-01
    • 1970-01-01
    • 2018-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多