<#22234 package_json fails with an exception for c...
# github-notifications
c
#22234 package_json fails with an exception for cycle in dependency graph Issue created by nikhila-dwarakanath-zocdoc Describe the bug Given a package.json file like below:
Copy code
{
     "name":"test",
     "scripts": {
           "depcheck": "yarn node ./depcheck.js",
     },
     "dependencies": {
           "depcheck": "^1.4.7",
     },
}
I have a package_json target with a node_build script for this script named
depcheck
. Getting this exception below:
Copy code
[ERROR] 1 Exception encountered:

Engine traceback:
  in `package` goal

CycleException: The dependency graph contained a cycle:
   :package_json#test
-> :package_json#depcheck
-> :package_json#depcheck

To fix this, first verify if your code has an actual import cycle. If it does, you likely need to re-architect your code to avoid the cycle.

If there is no cycle in your code, then you may need to use more granular targets. Split up the problematic targets into smaller targets with more granular `sources` fields so that you can adjust the `dependencies` fields to avoid introducing a cycle.

Alternatively, use Python dependency inference (`--python-infer-imports`), rather than explicit `dependencies`. Pants will infer dependencies on specific files, rather than entire targets. This extra precision means that you will only have cycles if your code actually does have cycles in it.
If I update the name of my script to
dep-check
, it works fine. Pants version 2.27.0.dev2 OS MacOS Additional info Add any other information about the problem here, such as attachments or links to gists, if relevant. pantsbuild/pants