npm-license-crawler icon indicating copy to clipboard operation
npm-license-crawler copied to clipboard

--onlyDirectDependencies option returns 0 results if package.json is missing a 'name' property

Open ATClemente opened this issue 5 years ago • 5 comments

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?

ATClemente avatar Jan 20 '20 02:01 ATClemente

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

mwittig avatar Feb 18 '20 12:02 mwittig

@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

mwittig avatar Feb 18 '20 12:02 mwittig

Any updates on this?

tmtakashi avatar Jun 19 '20 02:06 tmtakashi

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 avatar Jul 08 '20 00:07 Kiesco08

@Kiesco08 's solution worked for me.

tdotdm avatar Mar 07 '21 20:03 tdotdm