设置ES6 Environment webpack

时间:2017-05-10 01:38:49

标签: webpack

我正在尝试创建一个es6环境

在我的es6文件夹中我有以下

ES6 = ROOT FOLDERR

App <--(folder name) Files within the folder. index.js
Build <--(folder name) Files within folder. Index.html
node_modules <--(folder name)

I also have a package.json within my main root folder and a webpack.config.js

when I ran an npm run build on my terminal to see if everything was working I got this message.

无效的配置对象。 Webpack已使用与API架构不匹配的配置对象进行初始化。   - configuration.output.path:提供的值“./build”不是绝对路径!

我还有一个在我的sublime文本3中打开的文件,文件名为npm-debug.log,其中包含以下信息

    0 info it worked if it ends with ok
    1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
    2 info using npm@3.10.10
    3 info using node@v6.10.3
    4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
    5 info lifecycle es6@1.0.0~prebuild: es6@1.0.0
    6 silly lifecycle es6@1.0.0~prebuild: no script for prebuild, continuing
    7 info lifecycle es6@1.0.0~build: es6@1.0.0
    8 verbose lifecycle es6@1.0.0~build: unsafe-perm in lifecycle true
    9 verbose lifecycle es6@1.0.0~build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/Petey/es6/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
    10 verbose lifecycle es6@1.0.0~build: CWD: /Users/Petey/es6
    11 silly lifecycle es6@1.0.0~build: Args: [ '-c', 'webpack' ]
    12 silly lifecycle es6@1.0.0~build: Returned: code: 1  signal: null
    13 info lifecycle es6@1.0.0~build: Failed to exec build script
    14 verbose stack Error: es6@1.0.0 build: `webpack`
    14 verbose stack Exit status 1
    14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
    14 verbose stack     at emitTwo (events.js:106:13)
    14 verbose stack     at EventEmitter.emit (events.js:191:7)
    14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
    14 verbose stack     at emitTwo (events.js:106:13)
    14 verbose stack     at ChildProcess.emit (events.js:191:7)
    14 verbose stack     at maybeClose (internal/child_process.js:886:16)
    14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
    15 verbose pkgid es6@1.0.0
    16 verbose cwd /Users/Petey/es6
    17 error Darwin 16.0.0
    18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
    19 error node v6.10.3
    20 error npm  v3.10.10
    21 error code ELIFECYCLE
    22 error es6@1.0.0 build: `webpack`
    22 error Exit status 1
    23 error Failed at the es6@1.0.0 build script 'webpack'.
    23 error Make sure you have the latest version of node.js and npm installed.
    23 error If you do, this is most likely a problem with the es6 package,
    23 error not with npm itself.
    23 error Tell the author that this fails on your system:
    23 error     webpack
    23 error You can get information on how to open an issue for this project with:
    23 error     npm bugs es6
    23 error Or if that isn't available, you can get their info via:
    23 error     npm owner ls es6
    23 error There is likely additional logging output above.
    24 verbose exit [ 1, true ]

我做错了怎么能解决这个问题?我只是想学习ES6,这太令人沮丧了!

1 个答案:

答案 0 :(得分:0)

您是否尝试将__dirname添加到输出路径?

    module.exports = {
     entry: ['./app/index.js'],
     output: {
      path: __dirname + './build',
      filename: 'bundle.js'
     }
    }