Could I treeshake node_modules when i build a nodejs backend project?
The node_modules is so big and there are too many small files in it,How can i treeshake it like the frontend do?
Too many small files in node_modules is not used in my project but when i want to deploy offline I must carry them from here to there.
node_modules
-- ramdajs
-- lodashjs
-- ...
How can I do treeshaking with node_modules in an express project.
Related
How to make vue (npm init vue#latest) and node/express server/api in root folder in a way that there are no duplicate
folders and files, like node_modules, .env files, etc.
Plan is to build client(spa) to public folder inside server(api), so everything is neat!
Is that usual practice?
I tried usual approach to generate everything separately, but no success in telling vite to install dependencies in node_modules outside client folder.
A similar question to Google App Engine - Deploy different folder with the same app.yaml, but more specific.
I'm attempting to deploy a MEVN stack application using Google App Engine's (GAE) NodeJS app process.
The application has the following general structure:
app
- server
- dist
- node_modules
package.json
package-lock.json
- client
- dist
- node_modules
package.json
package-lock.json
app.yaml
package.json
package-lock.json
In an ideal world, when I run gcloud app deploy, I'd like for GAE to install the production dependencies for both my server and client folders (or sub-applications).
In attempting this, I've run up against a number of obstacles:
GAE's file-system is read-only, so I cannot manually specify any commands to install the dependencies within each sub-folder (throws an error).
In the app directory, I have toyed around with having another package.json file (as you can see in the above folder structure example) that lists the client and server modules as dependencies themselves. While this works to install all the dependencies for client and server, the node_modules folder that is created is then located in the app directory and thus unable to be accessed from within server and client.
I'm sure that what I'm looking for is possible by just having two GAE instances running simultaneously, one for client and the other for server.
But I'd like for this to be possible with just one GAE instance.
Any help is greatly appreciated!
I'm new in angular and every time I want to create new angular application it downloads approximately 316MB files from internet.
I was wondering if there is any way to skip downloading node_modules folder and just download other angular files neccessary to run my app and then copy&paste my (existing) node_modules folder to root folder of my app.
you can run the command ng new <YourProjectName> --skip-install, It will create a package without node_modules folder.
Yes, it's possible. Copy package.json, package-lock.json and node_modules. node_modules usually doesn't contain any project specific files or configurations.
I have a project on Laravel 5.4; I'm absolutely new to front-end package managers.
I used npm to install 4 packages in my project, so my node_modules folder has about 210 MB.
I used Laravel Mix to combine in groups required dependencies and files, then I run npm run dev.
My webpack.mix.js looks like :
let mix = require('laravel-mix');
mix
.copy('node_modules/jquery/dist/jquery.js', 'public/js')
.combine([
'node_modules/video.js/dist/video-js.min.css',
'node_modules/videojs-record/dist/css/videojs.record.css'],'public/css/recordDependencies.css')
.combine([
'node_modules/video.js/dist/video.min.js',
'node_modules/recordrtc/RecordRTC.js',
'node_modules/webrtc-adapter/out/adapter.js',
'node_modules/videojs-record/dist/videojs.record.js',
'node_modules/jquery/dist/jquery.js',
'node_modules/blueimp-file-upload/js/vendor/jquery.ui.widget.js',
'node_modules/blueimp-file-upload/js/jquery.iframe-transport.js',
'node_modules/blueimp-file-upload/js/jquery.fileupload.js'
], 'public/js/recordDependencies.js');
So, it generates me this files. Making a small test, I replaced the node_js directory out of the project, and everything still works.
So, the question is :
Can I delete this huge folder - node_modules, or it must live in
kernel of my project, at the deploying as well ?
In frontend applications node_modules are only required for compiling resources. You would not want to deploy node_modules because they contain unobfuscated code. Only deploy compiled files.
I have a project in which I use node-webkit. node-webkit allows npm packages to be used for developing desktop applications. I make use of grunt to build my application.
My folder structure looks like this at the moment:
project root
node_modules/ (1)
package.json (1)
App/
node_modules/ (2)
package.json (2)
bower.json
bower_components/
...
controllers/
filters/
...
app.js
The npm dependencies for the application itself are kept within the App folder, but the dev dependencies for building the project are not related to the application source code, so i keep them in node_modules (1) inside the root folder. I also know that in a package.json file one can express dependencies and dev dependencies, exactly for this reason. I would rather have one package.json file in the root expressing ALL dependencies, including dev dependencies, but i would rather have a separation of those dependencies on folder level.
Two questions arise:
Is this a good way to organize my npm dependencies? If yes, awesome? If no, which I expect:
What is a better way to organize my dependencies? Is it possible to specify that dev dependencies go into folder a, and 'regular' dependencies go into folder b? If so, how do I do this?
In case anyone is wondering, this is the project i am talking about:
https://github.com/michahell/pinbored-webkit
[updated folder structure to include app.js for clarity]
It is perfectly fine to keep more than one package.json file and multiple node_module directories for a project. If you consider the parts as separate components.
An example might be if, you have one directory containing a node server, another containing a react app, and a third containing some kind of deployment script written in javascript.
#Michael package.json file contains all the dependencies related to that project.There is no need for multiple package files and multiple node_modules folders..
But you need to check where is your App.js file!!
your App.js , package.json must be in same folder unless configured.