Is it necessary to copy all modules from node_modules directory, including devDependencies?
See original GitHub issueI have this package.json
{
"nativescript": {
"id": "org.nativescript.test1",
"tns-android": {
"version": "1.4.0"
}
},
"dependencies": {
"tns-core-modules": "1.4.0"
},
"devDependencies": {
"babel": "^5.8.29",
"gulp-debug": "^2.1.2"
}
}
I have some devDependencies
modules, and of course, after install, they are placed to node_modules
. After build, all of them are copied to platforms\android\src\main\assets\app\tns_modules\
. (app-debug.apk contains it too)
I’m using devDependencies
modules for building and testing only.
Is it really necessary to copy them all?
Issue Analytics
- State:
- Created 8 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
node.js - Is it safe to copy node_modules? - Stack Overflow
In general it should be fine - I copy the node_modules directory sometimes from my other projects to speed up the setup process....
Read more >Should I commit the node_modules folder to Git? - Flavio Copes
Not committing node_modules implies you need to list all your modules in the package.json (and package-lock.json ) as a mandatory step.
Read more >How To Use Node.js Modules with npm and package.json
The first step will be to create and understand the package.json file. You will then use it to keep track of all the...
Read more >Cleanup the node_modules for a lighter Lambda Function
Any nodejs project carries a bulky folder - the node_modules - that carries all the modules and dependencies that the application would need...
Read more >Reliable Development Workflows for Local Node ...
Not all of these modules ship with the products, ... has its own node_modules directory tree (since it specifies devDependencies on React ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @unlight ,
Thanks for sharing the steps to reproduce. In fact there are two different “issues” here. The first one is related to npm3 as you have noticed. It really flattens the dependencies and when we process them, we do not know if they are from dependencies or devDependencies section of any module. The issue occurs whenever you install npm package with
npm i
(when you are using npm 3). The workaround is to removenode_modules
directory and execute yourtns
command, for exampletns build android
. One of the first steps that we execute during preparing the project is to ensure all dependencies are installed. In case you do not havenode_modules
directory, we’ll install the dependencies with the npm version that we have in our nativescript-cli (2.14.12 - https://github.com/NativeScript/nativescript-cli/blob/master/package.json#L57). This way all packages will be installed correctly (as we are using npm 2) and we’ll prepare them correctly in the native project. The other issue is one implementation detail in our logic - when we processnode_modules
we get all directories (and subdirectories and subsubdirectories, etc.) and we filter only the ones that are devDependency of any package. When a package in node_modules is not defined anywhere in any package.json, we do not filter it as it is not defined as devDependency.Hope this makes sense for you 😃
I think this issue must be open again since I found out if we install npm module as a dev dependency then it won’t get copied to the tns_modules folder hence it will run error at run time. So the fix is to remove the platform and re-add it again and install the module as a runtime dependency.