Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting npm ERR! ENOTDIR: not a directory while installing package which depends on another

Tags:

node.js

npm

Note: I have latest npm and node versions. I have tried the answers provided in npm install error ENOTDIR but didn't work for me.

I need to install 2 npm modules got as .tgz packages on NodeRed

1. x.tgz
2. y.tgz

I could install the first package using npm install path/to/x.tgz

I used the same command npm install path/to/y.tgz command but I am getting following error.

malintha@malintha-VirtualBox:~/.node-red$ sudo npm install path/to/y.tgz 

npm ERR! path path/to/y.tgz/x.tgz

npm ERR! code ENOTDIR
npm ERR! errno -20
npm ERR! syscall stat
npm ERR! ENOTDIR: not a directory, stat 'path/to/y.tgz/x.tgz'

According to the error log, y module is looking for x.tgz inside it. Then I checked the package.json of y.tgz artefact.

I can see it has x.tgz as the dependency inside it, but it don't have x.tgz inside it.

 "dependencies": {
    "@abc/pqr": "file:x.tgz",
    "ajv": "^6.5.1",
    "debug": "^3.1.0"
  }

According to the instructions, it should be fine if I install the x.tgz and then y.tgz. I could install these x and y some time back but now I cannot install it.

What might be the root cause for this issue? Is this npm and node versions related issue?

like image 393
Malintha Avatar asked Dec 20 '18 12:12

Malintha


1 Answers

I'm re-writing this answer after deleting my old answer. I tested it with and node v11.6.0 and npm v4.5.0-next.0 on Linux.

To install y.tgz, I tried as below:

  1. I copied both tgz files in the same directory.
  2. I modified package.json of y.tgz as below:

    "dependencies": {
        "@abc/pqr": "file:../x.tgz",
        "ajv": "^6.5.1",
        "debug": "^3.1.0"
    }
    

dependencies supports file: + relative path or absolute path.

So, you can choose anyone as your development condition.

like image 80
Anselmo Park Avatar answered Nov 15 '22 05:11

Anselmo Park