2017-01-12 3 views
1

Ich hämmere meinen Kopf gegen eine Wand mit Webpack. Aus irgendeinem seltsamen Grund gibt Webpack weiterhin den Fehler "ERROR in (webpack) /package.json" aus, aber ich verstehe nicht einmal, warum es versuchen würde, diese Datei zu lesen. Es ist nicht in der Webpack-Konfigurationsdatei enthalten.
Meine Befehlszeile:Webpack kann webpack.json nicht lesen (aber warum sollte es funktionieren)

webpack -c webpack.config.vendor.js

meine webpack.config.vendor.js Datei weder direkt noch indirekt nicht diese package.json enthält:

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 } }) 
    ]) 
}; 

Also, warum dieser Fehler Ich erhalte?

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) 

Antwort

1

Verwenden webpack --config webpack.config.vendor.js, -c ist der falsche Parameter.

+0

Autsch (Kopf schlägt Tastatur). Danke! – Sam

+0

Grund für den Fehler: webpack liest die Standardkonfigurationsdatei 'webpack.config.js' und versucht, die angegebene Datei' webpack.config.vendor.js' zu laden, die ein 'require ('webpack')' 'enthält webpack lädt 'webpack', welches seine' package.json' benötigt ... und dann weiß webpack nicht, wie man json lädt. – Lars

Verwandte Themen