Coder Social home page Coder Social logo

copy-node-modules's People

Contributors

arloliu avatar bessonov avatar dependabot[bot] avatar drsensor avatar estaub avatar ezze avatar krzysztof-miemiec avatar mbjedk avatar sirmomster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

copy-node-modules's Issues

Latest release 1.1.0 breaks backwards compatibility

Since the code switched to use export, this broke backwards compatibility for existing implementations.

Now instead of const copyNodeModules = require('copy-node-modules'); one needs to use
const copyNodeModules = require('copy-node-modules').default;

Why didn't the semver change to 2.x to indicate this breaking change?

Resolve and include symlinks

Local repos installed with npm i <path-to-dir> or linked with npm link <path-to-dir> are not included in the target node_modules. I suggest to make a hard copy of the sym links content within the target node_modules.

Deeply nested dependencies are not copied

To reproduce:

~ $ mkdir tmp
~ $ cd tmp
~/tmp $ npm i --save [email protected]
~/tmp $ npm i --save-dev copy-node-modules
~/tmp $ npm ls @mongodb-js/saslprep
tmp@ /home/mpsijm/tmp
└─┬ [email protected]
  └─┬ [email protected]
    └── @mongodb-js/[email protected] deduped

~/tmp $ mkdir dist
~/tmp $ npx copy-node-modules . dist
~/tmp $ cd dist
~/tmp/dist $ npm ls @mongodb-js/saslprep
/home/mpsijm/tmp/dist
└── (empty)

In this example, the nested dependency @mongodb-js/saslprep should be copied to dist/node_modules (as dependency of mongodb, but it's not. Note that mongodb itself is copied, even though its dependencies are not:

~/tmp/dist $ npm ls mongodb
/home/mpsijm/tmp/dist
├── [email protected] extraneous
└─┬ [email protected] extraneous
  └── [email protected] deduped

This is probably because mongodb exists at the top-level node_modules folder, whereas @mongodb-js/saslprep does not.

System info:

  • Arch Linux
  • Node v18.18.0
  • NPM v10.2.1

Copy .bin folder

Any files from the source directories ./node_modules/.bin directory won't be copied over.
This can cause issues if you're copying modules with binaries since you'll have to manually copy over the bin folder yourself.

Allow to copy to dstDir variable directly

From the documentation:
dstDir: destination directory to copy modules, the modules will copy to dstDir/node_modules directory.

Should be possible to copy directly to dtsDir, without appending node_modules directory?

Travis CI support

I propose to enable Travis CI support for this repository in order to control code style and provide some tests in the future. It can be enabled here. Unfortunatelly, I don't have enough rights for that.

Directories with parent directories

copy-node-modules is failing trying to create folders with unexistant parent folders.

ie:
@angular/common

it is trying to create 'destination_path/@angular/common' but @angular folder does not exist, so it is showing an error and aborting.

Error: EMFILE, too many files open

I encountered the following error using this module:

Error: EMFILE: too many open files, open '/var/data/store/nfsshare/soft/copy-node-modules-emfile/node_modules/spdx-exceptions/README.md',Error: EMFILE: too many open files, open '/var/data/store/nfsshare/soft/copy-node-modules-emfile/dist/node_modules/spdx-exceptions/README.md',Error: EMFILE: too many open files, open '/var/data/store/nfsshare/soft/copy-node-modules-emfile/node_modules/spdx-exceptions/index.json'

While everything works fine on Ubuntu 16.04 LTS on my local machine, I get the error on CentOS 7 on the server.

Here is a related question on StackOverflow. I tried to use graceful-fs instead of fs as it proposed there but it doesn't work.

I created a repo reproducing this issue.

No such file or director if address package-name mismatch

Thanks for the useful package! Just what I need.

Apparently yarn and npm use the name from either the dependencies or from the address for the directory in node_modules, while copy-node-modules uses the package's name from it's packages.json.

If the maintainer did a mistake, this will result in copy-node-modules to fail, while yarn and npm work file.

Example:

packages.json

  "dependencies": {
    "jquery.accessible-accordion": "nomensa/jquery.accessible-accordion",

node_modules/jquery.accessible-accordion/package.json

  "name": "jquery-accessible-accordion",

Results in copy-node-modules failing:

$ copy-node-modules
Error: Error: ENOENT: no such file or directory, stat '…/node_modules/jquery-accessible-accordion'

Thanks for having a look.

Migrate from NCP to CPR

As stated by the developer of NCP, NCP is buggy and not maintained. CPR solves issues of NCP and is almost identical in there API. I recommend a change from NCP to CPR. (There filter method also works better). I can make the changes and create an pull request if you approve the idea.

Reference:
AvianFlu/ncp#100

Error thrown if dependencies key is missing

Based on commit 0140808
lines 129 and 137 of src/index.js
should be changed into
Object.keys(pkgContent.dependencies || {}).forEach((name) => {
and
Object.keys(pkgContent.devDependencies || {}).forEach((name) => {
respectively.
In other words, add || {} when accessing dependencies and devDependencies, as you already do it on line 67.

Does not work with monorepo

It seems that only local node_modules are copied. I need to copy some subset of node_modules (even hoisted to the root of monorepo) before deploying AWS lambda to the cloud.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.