Skip to content

ERROR in The "path" argument must be of type string. Received an instance of Object #496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
blasterbug opened this issue May 25, 2020 · 19 comments · Fixed by #586
Closed

Comments

@blasterbug
Copy link

blasterbug commented May 25, 2020

When compiling after updating from copy-webpack-plugin@6.0.0 to 6.0.1, I got this error (that seems be thrown by mini-css-extract-plugin).
"""
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Object
"""

I am not sure if it's an actual bug, but I post this here since the only thing that changed when I got this error is the version for mini-css-extract-plugin.

I can try to make a minimal project to reproduce the errors, but seems overkill for me right now.

  • Operating System: MacOS 10.15.4 (happen also int he Google Cloud build environment)
  • Node Version: 14.2.0 (and node:13-alpine on Gcloud build)
  • NPM Version: 6.14.5
  • webpack Version: 4.43.0
  • copy-webpack-plugin Version: 6.0.1
@alexander-akait
Copy link
Member

Without reproducible test repo I can't help, sorry

@alexander-akait
Copy link
Member

alexander-akait commented May 25, 2020

Minimum - please provide full stack trace of an error

@bitabs
Copy link

bitabs commented May 26, 2020

@blasterbug You should update how you call copy-webpack-plugin. I managed to make it work by doing the following:

module.exports = () => ({
  //...
  plugins: [
    new CopyWebpackPlugin({
      patterns: [
        {
          from: 'public',
          globOptions: {
            ignore: ['public/service-worker.js'],
          },
        },
      ],
    }),
  ],
)}

@alexander-akait
Copy link
Member

alexander-akait commented May 27, 2020

Also mini-css-extract-plugin and copy-webpack-plugin uses difference hooks, please update the issue using template and I will reopen the issue, can't help without configurations/reproducible test repo/reproducible steps

@blasterbug
Copy link
Author

this is how I set up the copy plugin:

new CopyWebpackPlugin({
        patterns: [
          {
            from: path.resolve(__dirname, 'public'),
            to: path.resolve(__dirname, 'dist'),
            globOptions: {
              dot: true,
              gitignore: true,
              ignore: [
                '*.html',
                '*.svg',
              ],
            },
          },
        ],
      }),

And this what I've got:

Child mini-css-extract-plugin node_modules/css-loader/dist/cjs.js??ref--4-1!node_modules/postcss-loader/src/index.js??postcss!node_modules/sass-loader/dist/cjs.js!src/styles/main.scss:
    Entrypoint mini-css-extract-plugin = *
    [9f2e4028ce7cb94562a7cbb58ade39bc] ./node_modules/css-loader/dist/cjs.js??ref--4-1!./node_modules/postcss-loader/src??postcss!./node_modules/sass-loader/dist/cjs.js!./src/styles/main.scss 12 KiB {0} [built]
        + 1 hidden module
    
    ERROR in The "path" argument must be of type string. Received an instance of Object
(node:90113) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)

@alexander-akait
Copy link
Member

@blasterbug Reproduced

@alexander-akait
Copy link
Member

Looks like bug in globby

@alexander-akait
Copy link
Member

sindresorhus/globby#145

@Legends

This comment has been minimized.

@alexander-akait

This comment has been minimized.

@liesahead

This comment has been minimized.

@AmreeshTyagi

This comment has been minimized.

@gregbenz
Copy link

gregbenz commented Jul 30, 2020

gitig

With copy-webpack-plugin 6.0.3, I'm also getting "ERROR in The "path" argument must be of type string. Received an instance of Object". The error is just that, no additional information and there is no clear indication that the failure is coming from copy-webpack-plugin (but it definitely is).

The error goes away if I do not use gitignore: true

My configuration:

		new CopyPlugin({
			patterns: [
				{
					from: './',
					to: '../dist/',
					context: './src/',
					globOptions: {
						dot: true,
						// gitignore: true, //In "copy-webpack-plugin": "^6.0.3", causes: ERROR in The "path" argument must be of type string. Received an instance of Object
						ignore: ['**/*.ts', '**/*.tif*', '**/*.tif', '**/*.md', '**/*.js', '**/libs/**', '**/*.doc'],
					},
				},
			],
		}),
	],```

@alexander-akait
Copy link
Member

@gregbenz Feel free to send a fix to globby

@gregbenz
Copy link

gregbenz commented Jul 30, 2020

@gregbenz Feel free to send a fix to globby

@evilebottnawi Sorry, I'm not sure what you mean. What would I do to use the gitignore flag without errors?

@alexander-akait
Copy link
Member

Send a fix to globby, here issue sindresorhus/globby#145

@alexander-akait
Copy link
Member

It is not problem by typescript, it is problem in globby package

@gregbenz
Copy link

It is not problem by typescript, it is problem in globby package

Thank you for catching that, I had multiple tabs opened and copied to the wrong one. Deleted from TS and added to globby.

@emresandikci
Copy link

I got same errors after the upgrade the plugin both of them

its working with this configs

const htmlPackPlugin = new HtmlWebPackPlugin({
  filename: 'index.html',
  template: 'src/public/index.html',
  hash: true,
});
const webpackCopyPlugin = new CopyWebpackPlugin({
  patterns: [
    {
      from: 'src/public',
      globOptions: { ignore: ['svg/*', '*.html', 'images/*'] },
    },
  ],
});

@cap-Bernardito cap-Bernardito mentioned this issue Feb 27, 2021
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants