【发布时间】:2017-08-20 08:35:23
【问题描述】:
我正在关注 Eve Porcello 的 Lynda.com - React.js essential training。在“使用 Webpack 构建”视频中,我完全按照作者描述的步骤操作,但“webpack”命令失败并出现以下错误,
配置对象无效。 Webpack 已使用与 API 模式不匹配的配置对象进行初始化。 - configuration.output.path:提供的值“dist/assets”不是绝对路径!
以下是我的 webpack.config.js 和 package.json 文件。
webpack.config.js
var webpack = require("webpack");
module.exports = {
entry: "./src/index.js",
output: {
path: "dist/assets",
filename: "bundle.js",
publicPath: "assets"
},
devServer: {
inline: true,
contentBase: "./dist",
port: 3000
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /(node_modules)/,
loader: "babel-loader",
query: {
presets: ["latest", "stage-0", "react"]
}
}
]
}
}
package.json
{
"name": "react-essential",
"version": "1.0.0",
"description": "A project focusing on React and related tools",
"main": "index.js",
"scripts": {
"start": "httpster -d ./dist -p 3000"
},
"author": "Indu Pillai",
"license": "MIT",
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-loader": "^6.4.1",
"babel-preset-latest": "^6.16.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"webpack": "^2.3.2",
"webpack-dev-server": "^2.4.2"
}
}
我一遍又一遍地重复这些步骤,但它不起作用。我对这个 webpack 很陌生,所以我无法找出真正的问题,以及它需要什么样的绝对路径。我还尝试了另一个(类似)问题的一些答案所建议的绝对路径,但这没有用。
谢谢!
【问题讨论】:
-
您提供的副本对我不起作用。
标签: javascript json reactjs npm webpack