2017-07-19 4 views
1

NPM、ノードおよびWebPACKのバージョンでは、私は標準のScala/PLAY2プロジェクトを作成しているのWebPACK modules.export

C:\>npm --version 
5.3.0 

C:\>node --version 
v6.10.2 

C:\>webpack --version 
3.3.0 

ある定義されていません。その中にapp/tsフォルダに4つのTypescriptファイル(Angular)を追加しました。私も(依存関係をダウンロードして、JSにTSを変換するWebPACKの実行)を実行し、物事を行うには

modules.export = { 
    entry: [ 
     '/ts/main.ts', 
     '/ts/vendor.ts' 
    ], 
    output:{ 
     filename:'[name].bundle.js' 
    }, 
    rules: 
     { 
      test:'/\.ts$/', 
      loader:'awesome-typescript-loader' 
     } 
} 

次のWebPACKの設定ファイルを作成している、私は遊びの設定を編集し、「打ち上げの前に」セクション(中2つのNPMコマンドを追加しました写真参照)。しかし、アプリケーションを実行するには、NPMの開始は、そのモジュールが定義されていないエラーを宣言IntelliJのコンソールで

`enter image description here

(webpack.config.jsで声明をmodules.exportする参照のうえ)

"C:\Program Files\JetBrains\IntelliJ IDEA 2017.1.3\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" run start --scripts-prepend-node-path=auto 

> [email protected] start C:\Users\Manu\Documents\manu\programs\scala\play_programs\temp\app 
> webpack 

C:\Users\Manu\Documents\manu\programs\scala\play_programs\temp\app\webpack.config.js:3 
modules.export = { 
^ 

ReferenceError: modules is not defined 
    at Object.<anonymous> (C:\Users\Manu\Documents\manu\programs\scala\play_programs\temp\app\webpack.config.js:3:1) 
    at Module._compile (module.js:570:32) 
    at Object.Module._extensions..js (module.js:579:10) 
    at Module.load (module.js:487:32) 
    at tryModuleLoad (module.js:446:12) 
    at Function.Module._load (module.js:438:3) 
    at Module.require (module.js:497:17) 
    at require (internal/module.js:20:19) 
    at requireConfig (C:\Users\Manu\Documents\manu\programs\scala\play_programs\temp\app\node_modules\webpack\bin\convert-argv.js:96:18) 
    at C:\Users\Manu\Documents\manu\programs\scala\play_programs\temp\app\node_modules\webpack\bin\convert-argv.js:109:17 

npm ERR! Windows_NT 10.0.14393 
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "start" "--scripts-prepend-node-path=auto" 
npm ERR! node v6.10.2 
npm ERR! npm v3.10.10 
npm ERR! code ELIFECYCLE 
npm ERR! [email protected] start: `webpack` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] start script 'webpack'. 
npm ERR! Make sure you have the latest version of node.js and npm installed. 
npm ERR! If you do, this is most likely a problem with the angular2-webpack package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  webpack 
npm ERR! You can get information on how to open an issue for this project with: 
npm ERR!  npm bugs angular2-webpack 
npm ERR! Or if that isn't available, you can get their info via: 
npm ERR!  npm owner ls angular2-webpack 
npm ERR! There is likely additional logging output above. 

npm ERR! Please include the following file with any support request: 
npm ERR!  C:\Users\Manu\Documents\manu\programs\scala\play_programs\temp\app\npm-debug.log 

Process finished with exit code 1 
+0

FYI nodejsはバージョン8で安定し、バージョン5でnpmが大幅に向上しました。[アップグレードを検討する](https://nodejs.org/)。ありがとうございます。 – msanford

答えて

1

あなたwebpack.config.jsは、module.exportsではなく、modules.exportで始まる必要があります。

"this module exports"は、プログラム上、平易な英語の同等語を意味します。

+0

私はすぐに答えを受け入れる(10分待たなければならない)。 '新しいエラーを投げます(設定ファイルや--output-filenameのどちらかで 'output.filename'が必要です)。'しかし、すでにwebpack.config.jsに出力を定義しています。 –

+0

それを聞いてうれしいです。それは確かに別の問題です。パスを指定していない可能性がありますか? 'output {}'オブジェクト(または、 'webpack.config.js'フォルダにある' __dirname'に相対的な、あなたの資産を望む場所)に 'path:__dirname +"/dist "、'を追加してみてください。 – msanford

+0

別のバグがオープンしました。私はパスを追加しましたが、それでも動作しません - https://stackoverflow.com/questions/45191495/webpack-doesnt-recognise-output-file-name –