question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

Nameless is Here!

So I’m trying to make a gulp task which optimises images (obviously). Here are my files:

gulpfile.esm.js

import gulp	from 'gulp';
import images	from './gulp/tasks/images.js';
import config	from './gulp/config.js';

const build = () => gulp.series(
	gulp.parallel(
		images.build
	)
);

const watch = () => gulp.series(
	build,
	gulp.parallel(
		images.watch
	)
);

let defaultTask;
if (config.env() === 'prod') {
	defaultTask = build;
} else {
	defaultTask = watch;
};

export default defaultTask;

./gulp/tasks/images.js

import gulp		from 'gulp';
import plumber		from 'gulp-plumber';
import changed		from 'gulp-changed';
import gulpIf		from 'gulp-if';
import imagemin		from 'gulp-imagemin';
import pngquant		from 'imagemin-pngquant';
import config		from '../config.js';

const build = () => (
	gulp.src(`${config.source.images}/**/*`)
		.pipe(plumber())
		.pipe(changed(config.build.images))
		.pipe(gulpIf(config.env() === 'prod', imagemin([
			pngquant({ quality: [ 0.8, 0.9 ] }),
			imagemin.mozjpeg({ quality: 80 }),
			imagemin.svgo()
		])))
		.pipe(gulp.dest(config.build.images))
);

const watch = () => gulp.watch(`${config.source.images}/**/*`, build);

export default { watch, build };

The error I get:

[21:14:04] Requiring external module esm
node_modules/gulp-imagemin/index.js:1
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
    at new NodeError (node:internal/errors:371:5)
    at validateString (node:internal/validators:119:11)
    at Object.basename (node:path:1309:5)
    at Error.<anonymous> (node:internal/errors:1450:55)
    at getMessage (node:internal/errors:421:12)
    at new NodeError (node:internal/errors:348:21)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1128:19) {
  code: 'ERR_INVALID_ARG_TYPE'

  • NodeJS version: 16.6.2
  • gulp version: 4.0.2
  • esm version: 3.2.25
  • gulp-changed version: 4.0.3
  • gulp-if version: 3.0.0
  • gulp-imagemin version: 8.0.0,
  • gulp-plumber version: 1.2.1
  • imagemin-pngquant version: 9.0.2

Any help is appreciated! Sorry for my terrible english.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

0reactions
ghostcommented, Oct 17, 2021

Hi there. Sorry for noticing so late. Currently, I don’t have resources to try it out, so I’ll close the issue and reopen it if anything goes wrong. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

The "path" argument must be of type string ... - Stack Overflow
I'm working on a project in React and ran into a problem that has me stumped. Whenever I run yarn start I get...
Read more >
[Fix] TypeError [ERR_INVALID_ARG_TYPE]: The “path ...
Have you run into the error “TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received undefined”? In this story I'll go...
Read more >
Why I got TypeError [ERR_INVALID_ARG_TYPE]: The "path ...
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null at new NodeError (node:internal/errors:278:15) ...
Read more >
The path argument must be of type string - Reactgo
In this tutorial, we are going to learn about how to fix the TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string....
Read more >
npm err! code err_invalid_arg_type npm err! the path ...
TypeError [ERRINVALIDARGTYPE]: The "path" argument must be of type string. Received an instance of Object at validateString (internal/validators.js:117:11) at ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found