With React and other frameworks it is now common to use npm and package.json to install the libraries you'll use on the frontend. If you are developing a universal/isomorphic app, this introduces the problem that the dependencies for the frontend and backend are stored in the same file, creating a massive dependency list.
If you use npm --save/--save-dev both types of dependencies (frontend, backend) become mixed and it's difficult to know, without going one by one, which one is used where.
Other than sorting and managing the dependency list by hand, is there any way to keep the list tidy? What are your strategies to manage dependency lists?
json just lists dependencies in alphabetical order by default, so I don't think it matters. You usually won't be manually adding the dependencies to your file, rather you'll be instructing npm to save packages as dependencies when you install them.
"dependencies" : Packages required by your application in production. "devDependencies" : Packages that are only needed for local development and testing.
For updating a new and major version of the packages, you must install the npm-check-updates package globally. It will display the new dependencies in the current directory whereas running this command will list all the global packages which have new releases.
If you need to add specific devDependencies to your project, you can use this command- 'npm install --save-dev'. This will add your desired npm library to the package. json file.
In a universal/isomorphic app, you'll probably have few dependencies that are purely frontend or purely backend; most of the dependencies are shared.
An option that comes to my mind is to use more than one package.json
:
I haven't used that structure myself, and I'm not sure that it will be more maintainable that a single package.json
, because you'll have to manage more things (and if you add npm-shrinkwrap to that, it's twice as more files).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With