Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Local dependency's dependencies unavailable during postinstall #18951

Open
1 of 4 tasks
chrismwendt opened this issue Oct 25, 2017 · 3 comments
Open
1 of 4 tasks

Local dependency's dependencies unavailable during postinstall #18951

chrismwendt opened this issue Oct 25, 2017 · 3 comments

Comments

@chrismwendt
Copy link

I'm opening this issue because:

  • npm is crashing.
  • npm is producing an incorrect install.
  • npm is doing something I don't understand.
  • Other (see below for feature requests):

What's going wrong?

I'm trying to build a local dependency dep1 during npm install, but dep1's dependencies are not installed under dep1/node_modules, which is causing its build step to fail. npm's flattening behavior seems to be causing the dependencies to be hoisted out of dep1/node_modules directory and into the root ./node_modules. This screenshot captures the situation:

image

Basically, I expect npm to provide all the dependencies necessary to build the local dependency during postinstall in the same way that the dependencies are available during prepublish when publishing to the npm registry.

How can the CLI team reproduce the problem?

diff --git a/dep1/package.json b/dep1/package.json
new file mode 100644
index 0000000..6494560
--- /dev/null
+++ b/dep1/package.json
@@ -0,0 +1,9 @@
+{
+    "name": "dep1",
+    "scripts": {
+        "postinstall": "ls"
+    },
+    "dependencies": {
+        "left-pad": "1.1.3"
+    }
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..0f39cd1
--- /dev/null
+++ b/package.json
@@ -0,0 +1,5 @@
+{
+    "dependencies": {
+        "dep1": "./dep1"
+    }
+}
  • Copy the diff above
  • git init && pbpaste | git apply && npm i

supporting information:

  • npm -v prints: 5.3.0
  • node -v prints: v6.11.3
  • npm config get registry prints: http://registry.npmjs.org/
  • Windows, OS X/macOS, or Linux?: Mac
@aajtodd
Copy link

aajtodd commented Apr 16, 2018

Also saw this with npm 5.8 / node 9.6.1

Last 4.x series of npm worked ok.

@Aminelahlou
Copy link

Hello,
I have exactly the same problem with npm 6.1.0 and node v8.11.2
I have to use npm 5.7 minimum I can't use 4.x series

@Aminelahlou
Copy link

I am available this week end if someone wants to pair on this bug 💃

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants