【发布时间】:2017-07-19 20:46:48
【问题描述】:
NPM、Node 和 webpack 版本是
C:\>npm --version
5.3.0
C:\>node --version
v6.10.2
C:\>webpack --version
3.3.0
我已经创建了标准的 scala/Play2 项目。在其中,我在 app/ts 文件夹中添加了 4 个 Typescript 文件(Angular)。我还创建了以下 webpack 配置文件
modules.export = {
entry: [
'/ts/main.ts',
'/ts/vendor.ts'
],
output:{
filename:'[name].bundle.js'
},
rules:
{
test:'/\.ts$/',
loader:'awesome-typescript-loader'
}
}
为了让事情运行(下载依赖项并执行 webpack 将 ts 转换为 js),我编辑了播放配置并在“启动前”部分添加了两个 npm 命令(见图)。但是在运行应用程序时,npm start 声明模块未定义的错误(参考 webpack.config.js 中的 modules.export 语句)
在 IntelliJ 控制台上
"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
> angular2-webpack@1.0.0 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! angular2-webpack@1.0.0 start: `webpack`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular2-webpack@1.0.0 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
【问题讨论】:
-
仅供参考,nodejs 现在稳定在版本 8,npm 在版本 5,带来了巨大的性能改进:consider upgrading。
标签: intellij-idea webpack