cascornelissen / svg-spritemap-webpack-plugin

SVG spritemap plugin for webpack
MIT License
211 stars 51 forks source link

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object #77

Closed maltheism closed 5 years ago

maltheism commented 5 years ago

Hi, svg-spritemap-webpack-plugin version 3.3.2 isn't working for me compared to the older version. I've tried without path.resolve and same error as well.

My configurations:

new SVGSpritemapPlugin([
            path.resolve(__dirname, 'public/images/app/icons/app/*.svg'),
            path.resolve(__dirname, 'public/images/app/icons/consumable/*.svg'),
            path.resolve(__dirname, 'public/images/app/icons/dance/*.svg'),
            path.resolve(__dirname, 'public/images/app/icons/emoji/*.svg'),
            path.resolve(__dirname, 'public/images/app/icons/human/*.svg'),
            path.resolve(__dirname, 'public/images/app/icons/pet/*.svg'),
            path.resolve(__dirname, 'public/images/app/icons/store/*.svg'),
            path.resolve(__dirname, 'public/images/app/icons/user/*.svg')
            ], {
        })

Output of npm run compile:

:Psychedelices alizee$ npm run compile

> psychedelices@1.0.0 compile /Users/alizee/Development/GitHub/Psychedelices
> webpack

/Users/alizee/Development/GitHub/Psychedelices/node_modules/webpack-cli/bin/cli.js:74
                                throw err;
                                ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object
    at validateString (internal/validators.js:107:11)
    at Object.normalize (path.js:1003:5)
    at module.exports (/Users/alizee/Development/GitHub/Psychedelices/node_modules/svg-spritemap-webpack-plugin/lib/options-formatter.js:19:20)
    at new SVGSpritemapPlugin (/Users/alizee/Development/GitHub/Psychedelices/node_modules/svg-spritemap-webpack-plugin/lib/index.js:31:24)
    at Object.<anonymous> (/Users/alizee/Development/GitHub/Psychedelices/webpack.config.js:152:9)
    at Module._compile (/Users/alizee/Development/GitHub/Psychedelices/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Module.require (internal/modules/cjs/loader.js:681:19)
    at require (/Users/alizee/Development/GitHub/Psychedelices/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at WEBPACK_OPTIONS (/Users/alizee/Development/GitHub/Psychedelices/node_modules/webpack-cli/bin/utils/convert-argv.js:115:13)
    at requireConfig (/Users/alizee/Development/GitHub/Psychedelices/node_modules/webpack-cli/bin/utils/convert-argv.js:117:6)
    at /Users/alizee/Development/GitHub/Psychedelices/node_modules/webpack-cli/bin/utils/convert-argv.js:124:17
    at Array.forEach (<anonymous>)
    at module.exports (/Users/alizee/Development/GitHub/Psychedelices/node_modules/webpack-cli/bin/utils/convert-argv.js:122:15)
    at /Users/alizee/Development/GitHub/Psychedelices/node_modules/webpack-cli/bin/cli.js:71:45
    at Object.parse (/Users/alizee/Development/GitHub/Psychedelices/node_modules/yargs/yargs.js:567:18)
    at /Users/alizee/Development/GitHub/Psychedelices/node_modules/webpack-cli/bin/cli.js:49:8
    at Object.<anonymous> (/Users/alizee/Development/GitHub/Psychedelices/node_modules/webpack-cli/bin/cli.js:375:3)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Module.require (internal/modules/cjs/loader.js:681:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (/Users/alizee/Development/GitHub/Psychedelices/node_modules/webpack/bin/webpack.js:156:2)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
    at internal/main/run_main_module.js:17:11
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! psychedelices@1.0.0 compile: `webpack`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the psychedelices@1.0.0 compile 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!     /Users/alizee/.npm/_logs/2019-05-26T00_05_07_903Z-debug.log
cascornelissen commented 5 years ago

Thanks for the report, I’ll look into this later today. Are you able to debug it a little by placing some console.logs in node_modules/svg-spritemap-webpack-plugin/lib/options-formatter.js?

maltheism commented 5 years ago

Thank you @cascornelissen for the help.

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object.

That points me to failing on line 19 pattern = path.normalize(pattern); because pattern is an array of strings (multiple paths ex: 'public/images/app/icons/app/.svg', 'public/images/app/icons/other/.svg', ...) and not a singular string.

Everything succeeds when I comment out line 19

cascornelissen commented 5 years ago

Ah, that seems obvious and so stupid I missed that (and no tests failed), will fix ASAP.

cascornelissen commented 5 years ago

@maltheism, I've just pushed a fix to master. Could you check if that works for you?

npm install cascornelissen/svg-spritemap-webpack-plugin#master
maltheism commented 5 years ago

@cascornelissen, the fix works! :)

cascornelissen commented 5 years ago

@maltheism, a fix for this bug has been released in version 3.3.3 🚀