Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Defining 'package' information in component.json and package.json

Tags:

gruntjs

bower

I'm creating a javascript library that I want make available through Bower to my internal company. I'm using Grunt to build my library.

My issue is that grunt's convention is to use package.json to define dependencies, library versions, dependencies, etc.

Bower, on the other hand, assumes that that same information is found in a component.json file.

What's the intended use of these two? They seem to serve essentially the same purpose. Do I need to create both and cut and paste the shared information?

like image 230
Roy Truelove Avatar asked May 10 '13 18:05

Roy Truelove


People also ask

What information can go into a package json file?

Your package. json holds important information about the project. It contains human-readable metadata about the project (like the project name and description) as well as functional metadata like the package version number and a list of dependencies required by the application.

How do I run a script defined package in json?

To define an NPM script, set its name and write the script under the 'scripts' property of your package. json file: To execute your Script, use the 'npm run <NAME-OF-YOUR-SCRIPT>' command. Some predefined aliases convert to npm run, like npm test or npm start, you can use them interchangeably.

What are Peerdependencies in package json?

Peer dependencies are a special type of dependency that would only ever come up if you were publishing your own package. Having a peer dependency means that your package needs a dependency that is the same exact dependency as the person installing your package.


2 Answers

We've gotten a lot of these kinds of question and everyone assumes we could share a lot metadata between these formats, but the reality is that only the name and version fields are sharable and only the version field changes regularly. If you find it cumbersome having to update two fields when you release something, there are tools out there that can automate this, eg. grunt-bumpx.

like image 191
Sindre Sorhus Avatar answered Oct 11 '22 20:10

Sindre Sorhus


package.json is intended for back-end purposes, in this case specify grunt tasks, node dependencies, etc. In the other side, bower.json is intended for front-end purposes.

like image 40
kevinwolf Avatar answered Oct 11 '22 21:10

kevinwolf