Skip to content

Confusing syntax error message when pointing to a package that does not exist #513

Open
@EdmundsEcho

Description

@EdmundsEcho

Thank you for this patch utility.

I'm using the latest (as of today), versions of the patch packages.

    "patch-package": "^8.0.0",
    "postinstall-postinstall": "^2.1.0",

Other versions:
node: 18.10.0
yarn: 1.22.21

When I go to create the patch using npx patch-package <mistaken-reference-to-non-existing-package> I get the following syntax error:

   ... /node_modules/fs-extra/lib/mkdirs/make-dir.js:85
      } catch {
              ^

SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (.../node_modules/fs-extra/lib/mkdirs/index.js:3:44)

The patch-package dependency that is causing the error:

    "fs-extra": "^9.0.0",

So, to be clear the operation works as expected when the package name is correct. However, if I make a mistake on the name of the package to be patched, it gives this error that suggests something else is wrong.

I hope this helps the next person interpret this error :))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions