Webpack无法读取webpack.json(但为什么会这样)

时间:2017-01-12 13:44:19

标签: webpack

我用webpack将头撞在墙上。由于一些奇怪的原因,webpack在(webpack)/package.json"中不断发出错误" ERROR,但我甚至不理解它为什么会尝试读取此文件。它不包含在webpack配置文件中 我的命令行:

  

webpack -c webpack.config.vendor.js

我的webpack.config.vendor.js文件不包含此package.json既不直接也不间接:

var isDevBuild = process.argv.indexOf('--env.prod') < 0;
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var extractCSS = new ExtractTextPlugin('vendor.css');

module.exports = {
    resolve: {
        extensions: [ '', '.js' ]
    },
    module: {
        loaders: [
            { test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, loader: 'url-loader?limit=100000' },
            { test: /\.css(\?|$)/, loader: extractCSS.extract(['css']) }
        ]
    },
    entry: {
        vendor: [
            '@angular/common',
            '@angular/compiler',
            '@angular/core',
            '@angular/http',
            '@angular/platform-browser',
            '@angular/platform-browser-dynamic',
            '@angular/router',
            '@angular/platform-server',
            'angular2-universal',
            'angular2-universal-polyfills',
            'bootstrap',
            'bootstrap/dist/css/bootstrap.css',
            'es6-shim',
            'es6-promise',
            'jquery',
            'zone.js',
        ]
    },
    output: {
        path: path.join(__dirname, 'wwwroot', 'dist'),
        filename: '[name].js',
        library: '[name]_[hash]',
    },
    plugins: [
        extractCSS,
        new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.DllPlugin({
            path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
            name: '[name]_[hash]'
        })
    ].concat(isDevBuild ? [] : [
        new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
    ])
};

那为什么我一直收到这个错误?

C:\[...]>webpack -c webpack.config.vendor.js
Hash: 344be4078e36e14984c6
Version: webpack 1.14.0
Child
    Hash: 344be4078e36e14984c6
    Version: webpack 1.14.0
    Time: 11549ms
             Asset     Size  Chunks             Chunk Names
           main.js   4.1 MB       0  [emitted]  main
    main-client.js  2.21 MB       1  [emitted]  main-client
       [0] ./webpack.config.vendor.js 1.84 kB {0} [built]
        + 743 hidden modules

    WARNING in ./~/chokidar/lib/fsevents-handler.js
    Module not found: Error: Cannot resolve module 'fsevents' in C:\p\Sam.Learning2\src\Sam.Learning2\node_modules\chokidar\lib
     @ ./~/chokidar/lib/fsevents-handler.js 7:17-36

    ERROR in (webpack)/package.json
    Module parse failed: C:\p\Sam.Learning2\src\Sam.Learning2\node_modules\webpack\package.json Unexpected token (2:9)
    You may need an appropriate loader to handle this file type.
    SyntaxError: Unexpected token (2:9)
        at Parser.pp$4.raise (C:\p\Sam.Learning2\src\Sam.Learning2\node_modules\acorn\dist\acorn.js:2221:15)

1 个答案:

答案 0 :(得分:1)

使用webpack --config webpack.config.vendor.js-c是错误的参数。