npm-license-crawler
npm-license-crawler copied to clipboard
--onlyDirectDependencies option returns 0 results if package.json is missing a 'name' property
This may be a bit of a unique scenario but I ran into an issue using npm-licence-crawler with an Expo project I am working on. I thought it would be relatively straightforward as I was following an article from the expo blog: https://blog.expo.io/licenses-the-best-part-of-your-app-29e7285b544f
I found that when running with the --onlyDirectDependencies option, I would always get 0 results. Running with the --dependencies flag returned a large number of results as expected.
I checked the code and determined this was because my package.json has no "name" property. Confirmed that adding a "name" property allows me to get results. My package.json file is this way because by default an Expo project is created with a package.json file that has no "name" property. Instead there is a name property put into an app.json file. Not sure if this has changed since the linked article was written.
I don't know if there are other node projects that could potentially be setup in a way that they would not have a name property so this might just be something people using expo need to watch out for. But perhaps its a scenario that could be handled somehow?
Thank you very much for your report. I'll check if it is possible to add a tweak to support Expo projects. Strictly speaking package.json file must have a name property as far as I understanding this, see https://docs.npmjs.com/files/package.json
@EvanBacon Apparently, a new Expo project is created with a package.json file that has no "name" property by default. Instead there is a name property put into an app.json file. Did you also experience this behavior at the time of writing and what is your view on this? My understanding is that a package.json descriptor shall have a name assigned, see https://docs.npmjs.com/files/package.json
Any updates on this?
I was able to get around this by adding name
and version
properties to my package.json
. i.e.
{
"name": "app-name",
"version": "1.0.0",
...
}
@Kiesco08 's solution worked for me.