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

npm 5.5: nested node_modules folders are ignored by pack. #18942

Closed
1 of 4 tasks
danShumway opened this issue Oct 24, 2017 · 7 comments
Closed
1 of 4 tasks

npm 5.5: nested node_modules folders are ignored by pack. #18942

danShumway opened this issue Oct 24, 2017 · 7 comments

Comments

@danShumway
Copy link

danShumway commented Oct 24, 2017

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?

npm pack does not bundle nested node_modules. I often take advantage of Node's require behavior to avoid relative paths when referencing other files and tests. I've found it to be a big help with keeping code refactorable and readable.

In npm 5.3 and below this works like a charm, but somewhere before 5.5.1, npm started skipping any node_modules folder, even if it's not associated with a package.json and not in the root directory.

This also impacts installs; if I try to publish a package with npm 5.5.1, the resulting package in the repo will be broken. If I publish the package with npm 5.3.0 and then install with npm 5.5.1, everything works great again.

Is this an intentional change?

How can the CLI team reproduce the problem?

npm init -y
mkdir -p src/node_modules
echo "console.log('hello');" > src/node_modules/foo.js

# in npm 5.3.0
tar tf $(npm pack)
# package/package.json
# package/src/node_modules/foo.js

#in npm 5.4.0 up to 5.5.1+
tar tf $(npm pack)
# package/package.json

supporting information:

@danShumway
Copy link
Author

Could possibly be related to #17708?

@danShumway
Copy link
Author

It looks like 9b72c4f42cf1 in npm-packlist will likely solve this issue. If I get time in the next few days I'll double check.

@ghost
Copy link

ghost commented Oct 26, 2017

I'm having the same problem, npm pack does not include the /node_modules directory, using npm v5.3.0 and node v8.6.0. I am also on Ubuntu

@danShumway
Copy link
Author

I manually updated npm to the most recent version of npm-packlist and the problem went away, so I suspect everything will be fine whenever the next version of npm is released.

As far as I know npm pack has never included the root node_modules directory, but 5.3.0 is including nested ones for me.

@ghost
Copy link

ghost commented Oct 30, 2017

Awesome thanks that worked!

For more details, I was trying to package the cordova node module directory located here:
node root dir/lib/node_modules. Inside the cordova directory is its own node_modules directory.

Using Node v8.6.0 & NPM v5.3.0, running the npm pack command skipped the node_modules directory from within the cordova directory. I was able to work around this by moving back to Node v6.11.4 & NPM v3.10.10 then running npm pack.

I've also now tried danShumway's solution to update npm-packlist for NPM 5.3.0. I did this by running npm install npm-packlist. After updating, then running npm pack on the cordova node modules directory, it successfully packed everything including the node_modules directory within cordova.

@danShumway
Copy link
Author

Pinging to make sure the issue doesn't get auto-closed by a bot before I get a chance to verify.

From what I can tell, this will be fixed in anything post v5.1.1 but I'll double check whenever a release happens.

@danShumway
Copy link
Author

danShumway commented Dec 8, 2017

Tested with npm v5.6.0 and npm pack now includes nested node_modules folders :)

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

1 participant