Skip to content
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

The "path" argument must be of type string. Received type undefined #354

Closed
ardieorden opened this issue May 24, 2020 · 14 comments · Fixed by #504
Closed

The "path" argument must be of type string. Received type undefined #354

ardieorden opened this issue May 24, 2020 · 14 comments · Fixed by #504

Comments

@ardieorden
Copy link

I'm currently getting this error when I try to use gh-pages:

The "path" argument must be of type string. Received type undefined

There's a previous issue that's similar to this (#308) and I saw that it was already fixed in the latest versions. I'm currently using gh-pages@2.2.0. My node version is v12.7.0 and my npm version is 6.10.0.

@ardieorden
Copy link
Author

Is anyone else getting the same error?

@yashrajb
Copy link

yes i am getting this error

@marzer
Copy link

marzer commented Jun 22, 2020

I was getting this error after the 3.1.0 update. Rolled back to 3.0.0 and everything worked OK.

@brendantang
Copy link

I was also getting this error and realized it happened when I either ran gh-pages without any options, or tried to pass an option and forgot the flag (as in gh-pages my-directory instead of gh-pages -d my-directory).

A more descriptive error would be helpful, but for now maybe try triple-checking for typos if you're still getting this error?

@webmaster128
Copy link

I get the error when executing npx gh-pages --message "Update docs [skip ci]" --dist cosmjs/docs_deployment --user "CI deployment <ci@cosmwasm.com>" --repo "git@github.com:CosmWasm/cosmjs.git" outside of a repo. Running the same command in the repo works. Downgrading to 3.0.0 resolves the problem here.

@brpaz
Copy link

brpaz commented Aug 16, 2020

I am getting the same error.
I dived into the code and I think I found the issue.

It´s on index.js:116.

  const clone = path.join(getCacheDir(), filenamify(repo));

The getCacheDir returns undefined in my case. Diving deeper, I found out it uses the find-cache-dir package, which has the following comment on the code:

Finds the cache directory using the supplied options.
 * The algorithm tries to find a `package.json` file, searching every parent directory of the `cwd` specified
 * (or implied from other options). It returns a `string` containing the absolute path to the cache directory,
 * or `undefined` if `package.json` was never found or if the `node_modules` directory is unwritable.

I don't have a package.json file in my project. that´s why I think I am getting undefined.

This only happens on 3.1.0. 3.0.0 works fine,

@chucklam
Copy link

chucklam commented Sep 7, 2020

I have the same problem/finding as @brpaz above. My static page is not in a nodejs repo, so there's no package.json or node_modules for find-cache-dir to get.

Looks like the change to use find-cache-dir was simply to move the cache directory out of the way of yarn2. If the need is just for a temporary directory, then tmp may be more appropriate than find-cache-dir.

@mahidul-islam
Copy link

Still getting the same issue any idea why??

@tnobile
Copy link

tnobile commented Apr 29, 2021

node ./node_modules/gh-pages/bin/gh-pages.js -d build
works

@sappelhoff
Copy link

reading the release notes for 3.1.0

The cache directory used by gh-pages is now node_modules/.cache/gh-pages. If you want to use a different location, set the CACHE_DIR environment variable.

perhaps this issue can be solved by making a new (temporary) dir and passing it to a CACHE_DIR env variable.

yous added a commit to yous/yous.be that referenced this issue Jul 21, 2021
@evaera
Copy link

evaera commented Sep 23, 2021

Still getting this error! Trying to publish without a package.json breaks it.

@1j01
Copy link

1j01 commented Apr 9, 2023

Adding --dist . fixed the error for me.


I was getting this error with gh-pages 5.0.0, whether running via npm script, npx, or node ./node_modules/gh-pages/bin/gh-pages.js, with or without arguments, with package.json present:

npx gh-pages --src "{index.html,built,lib,tabs,impulses}/**/*"
gh-pages --src "{index.html,built,lib,tabs,impulses}"
gh-pages
node ./node_modules/gh-pages/bin/gh-pages.js --src "{index.html,built,lib,tabs,impulses}"
mkdir -p .gh-pages-cache && CACHE_DIR=.gh-pages-cache gh-pages --src "{index.html,built,lib,tabs,impulses}"
mkdir -p .gh-pages-cache && CACHE_DIR=$(realpath .gh-pages-cache) gh-pages --src "{index.html,built,lib,tabs,impulses}"

Debugging this with VS Code launch.json...

{
	"version": "0.2.0",
	"configurations": [
		{
			"type": "node",
			"request": "launch",
			"name": "Debug gh-pages",
			"skipFiles": [
				"<node_internals>/**"
			],
			"program": "./node_modules/gh-pages/bin/gh-pages.js",
			"outFiles": [
				"${workspaceFolder}/**/*.js"
			]
		}
	]
}

I found that was failing here:

function publish(config) {
  return new Promise((resolve, reject) => {
    const basePath = path.resolve(process.cwd(), program.dist);

program.dist is undefined

By the way, this sort of error would be easier to track down if it logged the err.stack instead of err.message here. If there are other errors where only the message is desired, treat them as a special case.

@domsleee
Copy link
Contributor

I also had this problem (even with a package.json) and it worked after I used the --dist option (same as #354 (comment))

This is the current behaviour for this (invalid) command:

❯ npx gh-pages dist
The "path" argument must be of type string. Received undefined

Is --dist a mandatory option? If so, I would suggest an error message like this:

❯ npx gh-pages dist
No base directory specified. The `--dist` option must be specified.

For clarity, the correct command in my case is npx gh-pages --dist dist.

Let me know if there is interest in a PR, I can add this error message and a scenario in gh-pages.spec.js 👍

@marzer
Copy link

marzer commented Aug 10, 2023

@tschaub mind giving this issue some attention? It's still affecting people three years on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.