npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

npm install code ENOPACKAGEJSON due to dependent repo

node version: 8.14 (need this specific version for my production environment)
npm version: 6.4.1

Full error message:

npm ERR! package.json Non-registry package missing package.json: <dependency repo>@<company's Gitlab address>/<dependency repo>.git.
npm ERR! package.json npm can't find a package.json file in your current directory.

What I’m trying to do: npm install dependencies for the main project, but for some reason a dependency (another repo hosted on the company’s Gitlab) keeps saying that the dependency is missing a package.json even though there is a package.json on the root level of said repo. The weird part is, I can git clone said dependency using the included path in the main project’s repo separately.

What I’ve tried:
sudo npm install just in case - doesn’t work
change protocol from https to ssh - doesn’t work
delete ~/.ssh/known_hosts to generate a new ssh key upon npm install - doesn’t work

Is it possible for me to clone then manually put the repo’s content into the node_modules file, along with manually creating its .bin?

You can npm install a folder, so you can certainly clone the repo yourself and use it for an install. It would be interesting to try even if not the work-around you end up with, in case it reveals some problem with the package.json.

@shadowspawn Thank you for your suggestion.

I did tried various other solutions, and one did managed to fix it: According to this link, I created an access token for my company’s Gitlab account, then changed my package.json line for that dependency to be git+https with the token appended, and npm install went through without a hitch.

According to my colleague who used macOS, they’d get a prompt to enter their credentials when connected to Gitlab. However, on my Ubuntu Budgie, that didn’t happen (or probably was trying to use my global config to authenticate).