2017-01-12 2 views
1

私はwebpackで壁に頭を打っています。いくつかの奇妙な理由から、webpackはエラー "ERROR in(webpack)/package.json"を出力し続けますが、なぜこのファイルを読み込もうとしているのか理解できません。 webpack設定ファイルには含まれていません。
私のコマンドライン:Webpackはwebpack.jsonを読むことができません(なぜそうでしょうか)

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

使用webpack --config webpack.config.vendor.js-cは間違ったパラメータです。

+0

オウ(ヘッドヒットキーボード)。 ありがとう! – Sam

+0

エラーの原因: webpackはデフォルトの設定ファイル 'webpack.config.js'を読み込み、' require( 'webpack') 'を含む' webpack.config.vendor.js'ファイルを読み込もうとします。 webpackは 'package.json'を必要とする' webpack'をロードします。そしてwebpackはjsonをロードする方法を知らない。 – Lars

関連する問題