David Gumm
David Gumm

Reputation: 39

Webpack type error 'TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type boolean (true)'

I have been fighting with this for a while now. When I go to run npm run dev I get the error listed below. I can just run webpack -mode dev and it work. It puts the output directly into my dest directory though. Here is the GitHub for my project and the Git Clone Link.

I am running:
- node: v12.16.1
- webpack: 4.42.1
- webpack-cli: 3.3.11

Error output:

> @ 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"
};

package.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": {}
}

Upvotes: 3

Views: 4037

Answers (1)

Lk77
Lk77

Reputation: 2462

i'm posting this here, it might help, i searched my issue on google, and found this thread.

in my case, i have a custom " optin " arg, that i'm using to optin features that are not included in the base build by default. I'm doing that because i have multiple entries and multiple outputs in the same project, and some entries are not always necessary, so i let the user optin for it.

Everything worked fine, but one day i misspelled it and wrote : npm run build.prod -- -optin=myfeature and i got this error, because it was missing one " - " before the optin argument.

So it was the -o argument that was enabled instead, and it was messing up with webpack outputs

Upvotes: 2

Related Questions