node.js - configuration.output.path:提供的值“public”不是绝对路径!使用 Webpack

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42940050/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:05:53  来源:igfitidea点击:

- configuration.output.path: The provided value "public" is not an absolute path! with Webpack

node.jslaravel

提问by Juliatzin

I'm using Laravel Mix, that is based on WebPack.

我正在使用基于 WebPack 的 Laravel Mix。

I had it working, and now, it fails with:

我让它工作了,现在,它失败了:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.output.path: The provided value "public" is not an absolute path!

If I delete my webpack.mix.js content, it still fails the same way.

如果我删除了我的 webpack.mix.js 内容,它仍然会以同样的方式失败。

Can you help me debug this error, I have no clue how to go forward.

你能帮我调试这个错误吗,我不知道如何继续。

I have already deleted the node_modules folder, and ran npm install, it is still failing.

我已经删除了 node_modules 文件夹,然后运行npm install,它仍然失败。

Any idea how should I solve this?

知道我应该如何解决这个问题吗?

回答by zono

Use __dirname

使用 __dirname

e.g.

例如

output: {
    path: __dirname + "/dist/js", // or path: path.join(__dirname, "dist/js"),
    filename: "bundle.js"
}

Getting: Error: `output.path` needs to be an absolute path or `/`

获取:错误:`output.path` 需要是绝对路径或`/`

回答by Nittany Nation

Lock webpack to 2.2.1 in composer.json

在 composer.json 中将 webpack 锁定到 2.2.1

"devDependencies": {
    ...
    "webpack": "2.2.1",
    "laravel-mix": "^0.8.1",
    ...
}

As referenced here:

正如这里所引用的:

https://github.com/JeffreyWay/laravel-mix/issues/595

https://github.com/JeffreyWay/laravel-mix/issues/595

回答by rap-2-h

Quoting this comment:

引用此评论

For anyone else wondering how to take advantage of that fix, you can edit your package.json and make sure your larave-mix version is 0.10 or higher:

"laravel-mix": "^0.10.0",

Then run npm update.

对于想知道如何利用该修复程序的其他人,您可以编辑 package.json 并确保您的 larave-mix 版本为 0.10 或更高:

"laravel-mix": "^0.10.0",

然后运行 ​​npm 更新。

I think the best (cleanest) solution is to update the Laravel Mix to last version (0.12 today)

我认为最好(最干净)的解决方案是将 Laravel Mix 更新到最新版本(今天是 0.12)

回答by Juliatzin

It seems to be a Laravel Mix Incompatibility with Webpack 2.3.0 --> https://github.com/JeffreyWay/laravel-mix/issues/595

这似乎是 Laravel Mix Incompatibility with Webpack 2.3.0 --> https://github.com/JeffreyWay/laravel-mix/issues/595

回答by Mykola Tofan

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration.output.path: The provided value "public" is not an absolute path! -> The output directory as absolute path(required).

无效的配置对象。Webpack 已使用与 API 架构不匹配的配置对象进行初始化。- configuration.output.path:提供的值“public”不是绝对路径!-> 输出目录作为绝对路径(必需)。