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



我正在用webpack用头撞墙。出于某种奇怪的原因,webpack 不断发出错误"ERROR in (webpack)/package.json",但我什至不明白为什么它会尝试读取这个文件。它不包含在 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:pSam.Learning2srcSam.Learning2node_moduleschokidarlib
     @ ./~/chokidar/lib/fsevents-handler.js 7:17-36
    ERROR in (webpack)/package.json
    Module parse failed: C:pSam.Learning2srcSam.Learning2node_moduleswebpackpackage.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:pSam.Learning2srcSam.Learning2node_modulesacorndistacorn.js:2221:15)

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

最新更新