Reputation: 8920
New to Electron I've seen a few dependencies installed with Bower. After referencing the Bower documentation it shows an install of Bower globally with:
npm install -g bower
Instead I wanted to learn if I could install everything at one executable command. After reading "adding bower as devDependency in package.json" I found that I could save it as a devDependencies
with:
npm i bower --save-dev
then I could create a bower.json file like the package.json file from "Creating Packages" and in my bower.json I have:
"dependencies": {
"font-awesome": "^5.7.2",
"jquery": "^3.3.1"
}
on the same level as package.json but when I research to see if I can install everything with npm i
instead of having to use:
bower i
In package.json is there a way to chain bower i
to npm i
so when the the project is cloned it will install everything including the Bower packages? I've been unable to find if this has been asked before from my searches.
Upvotes: 1
Views: 538
Reputation: 408
Yes, there is. It's enabled using a feature called scripts
in npm
. npm
provides hooks for you to trigger your script. I recommend using the postinstall
hook which will run bower i
after you run npm i
.
Adapting from the docs:
{
"name": "foo",
"version": "1.0.0",
"scripts" :
{
"postinstall" : "bower i"
}
}
Upvotes: 1