11

I'm getting an error similar to this post and I've checked to see if I could resolve it in the same way, but it appears to be a different issue.

Whenever I try to push, deploy or convert to metadata, I'm getting the error

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

This error also shows up in the Problems tab in VS Code, but clicking on it gives me another error (Unable to open "": File is a directory.)

enter image description here

This issue was reported on the github/cli forum by others over the last 8-9 months, but there's no clear resolution. I've added more detail (json error output) there.

The only "path" argument I can find is in the sfdx-project.json, and it's clearly a string:

{
  "packageDirectories": [{ "path": "force-app", "default": true }],
  "namespace": "",
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "46.0"
}

I'm completely stuck with no clear way to debug this. Would appreciate any ideas...

3
  • Did you try creating a new scratch org to target?
    – Phil W
    Aug 9, 2019 at 6:02
  • It won't let me even convert to mdapi where no org is involved. Something is internally off with the source. Aug 9, 2019 at 6:10
  • 1
    I'm thinking the error message is just wrong, and there may be an errant remnant from the merge conflict resolution. I'm currently searching for things like <<<<< HEAD etc. Also combing through the .forceignore file. Aug 9, 2019 at 15:49

4 Answers 4

10

FIXED IT! I found that I could do a sfdx force:source:deploy -p [filepath] on individual files and on directories. So, I started at the top and worked my way down.

sfdx force:source:deploy -p force-app/main/default = same error

sfdx force:source:deploy -p force-app/main/default/applications = success

sfdx force:source:deploy -p force-app/main/default/appMenus = success

sfdx force:source:deploy -p force-app/main/default/aura = success

sfdx force:source:deploy -p force-app/main/default/classes = success

...etc., until sfdx force:source:deploy -p force-app/main/default/staticResources = SAME ERROR

So I stepped into that directory and discovered a meta file for a graphic (png) that was missing. I pulled the png from my other files (not in the project), added it to the directory, then did...

sfdx force:source:deploy -p force-app/main/default/staticresources = SUCCESS

So then, I tried sfdx force:source:push and SUCCESS!

WHAT HAVE WE LEARNED?

  1. That error message is not at all helpful and appears to occur when there's a variety of errors in the package you're trying to push.
  2. If you can still use deploy (I could), start at the top and work your way down until you can isolate the directory/file where the error originates.
5
  • Very helpful! I had the exact same issue and this approach helped me diagnose it. Nov 20, 2019 at 21:04
  • I had the same error after I accidentally copied a "Object" folder into the parent directory. Additional help for anybody debugging this: delete the scratch cache in .sfdx/orgs/username@example.com after you fixed the folder structure. Dec 9, 2019 at 15:23
  • Do you have to use " these " or nah ? Or these ' ' you didn't use them I tried all three and none worked. Feb 13, 2021 at 20:50
  • I just used the cli with no single or double quotes. The only quotes in this post are about the path file, which ended up not being significant. No changes to that. Feb 13, 2021 at 21:13
  • For us, the inclusion of object translations cause sfdx to choke and throw this error. We had to remove them and reset everything in ~/.sfdx/ Jan 5 at 14:36
2

This can happen if you put an object definition into a folder that SFDX doesn't recognize. For example, this happened to me when i put a Custom Metadata definition in a folder labelled 'customMetadata' (it expected a folder called 'objects', apparently).

1
0

According to me, There must be an invalid static resource. Please verify your static resource files.

0
0

I had the same issue, but it was related to copy & paste file, when vsc added " copy" to the file name. Agree that error message should be better.

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    May 16 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.