I run into an issue where the generator would fail with an error \<package name>: unable to locate package.json .
The package for which the script fails to locate the package.json is inside a node_module directory of another local package which is referenced by a relative path in my main project.
local package directory structure:
../mylocalPackage/node_module/\<name of the package for which the generator failed>
Note, the package for which the generator fails to find package.json is not a direct dependency of the local package(not listed in its package.json).
The packagePath used here is incorrect for the scenario described above.
Workaround
The package.json is usually located next to the license file so I decided to add one more check for package.json at the location of the license file. I simply added else if on the line 139 before giving up.
else if (!itemAtPath) { packageJson = jetpack.read(path.join(path.dirname(package['licenseFile']), 'package.json'), 'json'); }
I run into an issue where the generator would fail with an error \<package name>: unable to locate package.json . The package for which the script fails to locate the package.json is inside a node_module directory of another local package which is referenced by a relative path in my main project.
For example:
mainProject package.json:
"dependencies: { "@mylocalPackageFoo: "file: ../mylocalPackage" }
local package directory structure: ../mylocalPackage/node_module/\<name of the package for which the generator failed>
Note, the package for which the generator fails to find package.json is not a direct dependency of the local package(not listed in its package.json).
The packagePath used here is incorrect for the scenario described above.
Workaround The package.json is usually located next to the license file so I decided to add one more check for package.json at the location of the license file. I simply added else if on the line 139 before giving up.
else if (!itemAtPath) { packageJson = jetpack.read(path.join(path.dirname(package['licenseFile']), 'package.json'), 'json'); }