scott113341 / npm-install-version

Installs node modules to versioned or custom directories.
MIT License
56 stars 11 forks source link

fails to install module when executed in cli using a postinstall script for a globally installed module #27

Open borisdiakur opened 7 years ago

borisdiakur commented 7 years ago

I’m trying to install and require major versions of lodash using a postinstall script for n_. However npm-install-version fails to install lodash. Here is how to reproduce the issue:

$ npm install n_@1.4.1 -g ; n_3

Here is the result:

$  ~/Workspace/n_ (master)$ ls -alh /usr/local/lib/node_modules/n_/node_modules/lodash\@\^3.10.1/
total 0
drwxr-xr-x  3 boris  admin   102B Dec 22 17:14 .
drwxr-xr-x  8 boris  admin   272B Dec 22 17:14 ..
drwxr-xr-x  2 boris  admin    68B Dec 22 17:14 node_modules
$ ls -alh /usr/local/lib/node_modules/n_/node_modules/lodash\@\^3.10.1/node_modules/
total 0
drwxr-xr-x  2 boris  admin    68B Dec 22 17:14 .
drwxr-xr-x  3 boris  admin   102B Dec 22 17:14 ..

References: https://github.com/borisdiakur/n_/issues/18

scott113341 commented 7 years ago

Thanks @borisdiakur, I'll look into this

DLehenbauer commented 5 years ago

I believe I've hit the same issue. Invoking 'nvi' from a postinstall script works on the first invocation of npm install, but all subsequent invocations of npm install fail with:

$ npm i                                                                                                                                                                 (perf✱)
npm ERR! path [...]/clarinet/node_modules/npm/node_modules/dezalgo
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '[...]/clarinet/node_modules/npm/node_modules/dezalgo' -> '[...]/clarinet/node_modules/npm/node_modules/.dezalgo.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/danlehen/.npm/_logs/2019-01-04T15_44_15_175Z-debug.log

To recover, I deleted my package-lock.json and /node_modules/.

Full repro:

$ git clone https://github.com/DLehenbauer/clarinet.git
$ cd clarinet
$ git checkout nvi-repro
$ npm i
$ npm i

The first npm i works as expected. The second fails as described above.

MacOS v10.14.2 node v8.11.4 npm v5.6.0