gpt4 book ai didi

javascript - Webpack 类型错误 'TypeError [ERR_INVALID_ARG_TYPE]: The "路径”参数必须是字符串类型。接收到的 bool 类型 (true)'

转载 作者:行者123 更新时间:2023-12-04 15:32:22 27 4
gpt4 key购买 nike

我已经为此奋斗了一段时间。当我去运行npm run dev我收到下面列出的错误。我可以运行 webpack -mode dev它工作。不过,它会将输出直接放入我的 dest 目录中。这里是 GitHub对于我的项目和 Git Clone Link .

我在运行:
- Node :v12.16.1
- 网络包:4.42.1
- webpack-cli:3.3.11

错误输出:

> @ dev %USERPROFILE%\source\repos\simple-router
> webpack --config webpack.config.dev.js -mode development --display-error-details

%USERPROFILE%\source\repos\simple-router\node_modules\webpack-cli\bin\cli.js:93
throw err;
^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type boolean (true)
at validateString (internal/validators.js:117:11)
at Object.isAbsolute (path.js:353:5)
at module.exports (%USERPROFILE%\source\repos\simple-router\node_modules\webpack-cli\bin\utils\convert-argv.js:34:13)
at %USERPROFILE%\source\repos\simple-router\node_modules\webpack-cli\bin\cli.js:71:45
at Object.parse (%USERPROFILE%\source\repos\simple-router\node_modules\yargs\yargs.js:567:18)
at %USERPROFILE%\source\repos\simple-router\node_modules\webpack-cli\bin\cli.js:49:8
at Object.<anonymous> (%USERPROFILE%\source\repos\simple-router\node_modules\webpack-cli\bin\cli.js:366:3)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (%USERPROFILE%\source\repos\simple-router\node_modules\webpack\bin\webpack.js:156:2)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
code: 'ERR_INVALID_ARG_TYPE'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `webpack --config webpack.config.dev.js -mode development --display-error-details`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! %USERPROFILE%\AppData\Roaming\npm-cache\_logs\2020-04-01T18_34_52_621Z-debug.log

webpack.config.js
const path = require("path");

module.exports = {
entry: "./src",
output: {
path: path.resolve(__dirname, "dist/js"),
filename: "simple-router.min.js",
publicPath: "/js/"
},
devtool: "source-map"
};

包.json
{
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "http-server --proxy http://localhost:8080? --log-ip",
"build": "webpack --config webpack.config.prod.js -mode --verbose",
"dev": "webpack --config webpack.config.dev.js -mode development --display-error-details"
},
"devDependencies": {
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11"
},
"dependencies": {}
}

最佳答案

我在这里发布这个,它可能会有所帮助,我在谷歌上搜索了我的问题,并找到了这个线程。
就我而言,我有一个自定义的“optin ” arg,我使用它来选择默认情况下不包含在基本构建中的功能。我这样做是因为我在同一个项目中有多个条目和多个输出,并且某些条目并不总是必需的,所以我让用户选择它。
一切正常,但有一天我拼错了它并写道:npm run build.prod -- -optin=myfeature我得到了这个错误,因为它在 optin 参数之前缺少一个“- ”。
所以它是启用了 -o 参数,它搞乱了 webpack 输出

关于javascript - Webpack 类型错误 'TypeError [ERR_INVALID_ARG_TYPE]: The "路径”参数必须是字符串类型。接收到的 bool 类型 (true)',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60978272/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com