arloliu / copy-node-modules Goto Github PK
View Code? Open in Web Editor NEWFast deploy Node.js modules from local source folder to distination folder
Fast deploy Node.js modules from local source folder to distination folder
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?
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
.
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:
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.
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?
For example, I've included the package imagesloaded as a dependency in my app, but I would like to prevent the ev-emitter dependency of imagesloaded from being copied over, since they provide a compiled js file already. Is this possible?
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.
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.
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.
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.
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
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.
When a module is updated with a new version in package.json, the dstDir isn't updated.
Should be possible to update the module in dstDir to match the updated module in package.json?
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.