2

I have a private package on the file system that I'm trying to install in an Angular 8 project. So far with non-angular projects, this has worked fine. From the root of the Angular project I do:

npm i -S ../the-other-project-dependency/dist

The error message is:

npm ERR! Could not install from "../the-other-project-dependency/the-other-project-dependency" as it does not contain a package.json file.

The part of this that is true is that the-other-project-dependency does not contain a package.json file.

The package.json file is in ../the-other-project-dependency/dist. Specifically, it is in the dist directory.

So I'm not sure if NPM is saying that the dist directory should be named the-other-project-dependency?

I tried renaming dist to the-other-project-dependency and now it gets passed that error, but it gives an error for another private project dependency:

Specifically it says:

`the-other-project-dependency/yet-another-private-dependency` could not be installed as it does not contain a `package.json` file.  

So it looks as if NPM does not understand how to work with locally installed packages. In this last case it seems as if it's saying the yet-another-private-package-dependency should be laid out as a sibling of the-other-project-dependency and it's not reading the file system path to that dependency.

I assumed per this post that using local file deps should just work.

Update

I think it's a bug in NPM. I filed a report here

Resolution

Was able to get it working using yarn, but I had to remove the local private packages and reinstall them with yarn, as yarn uses a slightly different path string for local dependencies.

Ole
  • 41,793
  • 59
  • 191
  • 359
  • 1
    hmm the content of package.json in that dist folder may be important especially `main` property value as it tell npm what file to use as entry point to use. Also try `npm i file:../the-other-project-dependency/dist` – Xesenix Jul 10 '19 at 19:17
  • @Xesenix I think you are onto something. I did not set up the `main` property right. I'm fixing it now, but running into some other compile errors so I"ll let you know if it works ASAP. – Ole Jul 10 '19 at 19:30
  • Hmm I fixed the `main` attribute, but I still get the `package.json` not found message. I don't get this if for example I install https://github.com/fireflysemantics/validator locally from the `dist` folder. – Ole Jul 10 '19 at 19:40
  • OK - It has something to do with me including other private dependencies. I stripped down the project to be dependency free, and it install fine. I'll start with a brand new bare project and build it up with the other project dependencies, until I start hitting this error. – Ole Jul 10 '19 at 20:41
  • 1
    It looks like it has to do with private transitive dependencies. For example if we have package `privateA` that depends on `privateB` and we install private A in the Angular project, it works as long as `privateA` does not depend on `privateB`. When `privateB` is installed in `privateA` and an attempt is made to install `privateA` in the Angular project npm will complain that it cannot install `privateB` ... – Ole Jul 10 '19 at 21:08
  • 1
    I think its an NPM Bug: https://npm.community/t/npm-is-generating-the-wrong-path-for-transitive-private-local-file-system-deps/8763 – Ole Jul 10 '19 at 22:56

0 Answers0