how to force bower to install a certain version of dependency - bower

Assume a bower.json file in which dependencies are like
"dependencies": {
"angular": "~1.5.x",
"angular-routing": "*",
"ngDialog": "*",
"requirejs": "*"
}
because angular-routing requires another version of angular (say 1.2.x), bower prompts me to choose a version.
How could I force bower to install angular ~1.5.x automatically?

I figured out the answer. I'm sharing for others:
If I add the dependency with my favorite version to resolutions in bower.json, Bower will automatically install it. Here is my updated bower.json:
"dependencies": {
"angular": "~1.5.x",
"angular-routing": "*",
"ngDialog": "*",
"requirejs": "*"
},
"resolutions": {
"angular": "~1.5.x"
}
More information here.
Update:
As Mattliu mentioned in comments, it's possible to answer with ! when any library asks for another version of an already installed dependency. this way you'll keep existing version and also npm creates resolution config automatically.

If you would like to install JQuery 2.1.4 strictly and add it to your bower.json dependencies you would go like this
bower install jQuery#2.1.4 --save

You need to specify the version in bower.json.
Note that using a tilde will automatically resolve to any newer minor version
So, specifying ~1.5.x would pull 1.5.1 if it existed
To specify an exact version, remove the tilde e.g. specify "1.5.1"

Related

Cannot find module 'babel-eslint' (both standard and babel-eslint already installed locally)

What version of standard?
12.0.1
What operating system, Node.js, and npm version?
Windows 10,
Node v10.15.1,
NPM v.6.8.0
What did you expect to happen?
I install both standard and babel-eslint on devDependencies
(locally).
I run standard --parser babel-eslint
I get the standard use babel-eslint parser to recognize babel code style and not stating
it as style error
What actually happened?
I install both standard and babel-eslint on devDependencies (locally).
I run standard --parser babel-eslint
I get error: Cannot find module 'babel-eslint'
I read from previous issues 85 1167, it should be fixed when they are installed on the same level. But it does not happen on mine.
I have tried to put config below on package.json:
"standard": {
"parser": "babel-eslint"
}
But it does not resolve the issue.
Hi this is an old question but for who passes here in the future, those answers didn't work for me, but this one did:
npm install babel-eslint --save-dev
Try
$yarn add standard babel-eslint
I solved this by doing:
npm install -g babel-eslint

Unable to resolve module `schedule/tracking`

So I made a react-native project that fully works on android now, but when I try to run it on ios I keep getting more problems.
picture
I know this question is already all over stackoverflow and the react-native github page, but all those answers don't seem to work for me and I doubt anyone checks those comments anymore.
I had a similar problem on another project but IIRC that was solved by updating my RN version.
Does anyone know what I did wrong here?
I already tried:
updating RN
downgrading RN
installing #babel/runtime: 7.0.0
installing schedule: 0.4.0
removing all the '^'-characters of the package version
remove node_modules and package-lock.json and reinstalling
...
package.json
"dependencies": {
"#babel/runtime": "7.0.0",
"react": "16.6.0-alpha.8af6728",
"react-native": "0.57.2",
"react-native-fetch-blob": "0.10.8",
"react-native-orientation": "3.1.3",
"react-navigation": "3.0.9"
},
"devDependencies": {
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.47.0",
"react-test-renderer": "16.6.0-alpha.8af6728",
"schedule": "0.4.0"
},
Few things that may guide you in the right direction.
Are you sure you want the dependency on the devDependencies section, instead of dependencies? Development dependencies are for the tooling used for your project, not the project itself. Importing code from devDependencies directly in your application code is a code smell. Also, which may be a case for you, some CI servers may not install devDependencies by default.
There is no tracking file in the 0.4 version of the package. However, there is a tracing.js file. Are you sure you're importing the right file? You can browse all files bundled in the package here.
As the documentation states: "This is a package for cooperative scheduling in a browser environment.". Are you're sure you can use it in React Native?
Last two points don't explain why it works on Android and not on iOS thou.
If you don't need schedule package directly, and you install it only because of the error, then you should remove it from package.json as it shouldn't be there in the first place (remember to remove node_modules / clean cache afterward).
This is an internal React package, and you should not use it directly unless you knew what you are doing. In this case, the root cause of the initial error is probably something different.

How can I tell bower where to install packages?

I'm figuring out how to install packages using bower.
When I 'bower install packagename', packages are installed in /app/components/.
However, I'd like to dictate the structure of my projects myself.
Is there a way to configure bower to install packages in particular places?
Bower can be configured using JSON in a .bowerrc file.
The directory setting is the path in which installed components should be saved.
If not specified it will be install in the default path.
So for example :
{
"directory" : "package/components",
"json" : "bower.json"
}
Here we tell bower to install packages in the subfolder package/components, and use a file named bower.json to store its data.

How to install latest (untagged) state of a repo using bower?

I have a very small repo in which I do all dev work in the master branch and use tags as "stable" points in history.
I guess by default Bower seems to fetch the latest tagged version of a repo. I'm trying to get the most recent commit in the master branch.
I've tried running all these, in every conceivable order:
bower cache-clean mypackage
bower install mypackage --force-latest
bower install mypackage --force --force-latest
bower install mypackage --force
I've also tried adding latest to my bower.json file:
"dependencies": {
"mypackage": "latest"
}
And then running:
bower update mypackage
No matter what it seems to always get the latest tagged state.
How do I get the latest, most up-to-date, untagged state of the project?
Specify a git commit SHA instead of a version:
bower install '<git-url>#<git-commit-sha>'
Example:
bower install 'git://github.com/yeoman/stringify-object.git#d2895fb97d'
You can also specify a branch instead of a SHA, but that's generally not recommended unless it's in development and you control all the parts.
Yes, you can point to the git url, or use name/repo shorthand (for github repos):
bower.json
{
"name": "bower-test",
"dependencies": {
"dpm": "git#github.com:okfn/dpm.git",
"docker-nmpjs": "terinjokes/docker-npmjs"
}
}
More in the docs
As #roi noted in the comments, you can use the --save flag to automatically add dependencies to bower.json, e.g. bower install terinjokes/docker-npmjs --save
You can install a branch in Bower > 1.0.0:
bower install xxx#foo-branch
More details at https://github.com/bower/bower/issues/107#issuecomment-22352689.
If you are using a bower.json file you specify the latest version of a branch with a line in either the dependencies or devDependencies as appropriate for your project configuration:
"angular-bootstrap": "git#github.com:angular-ui/bootstrap.git#bootstrap3",
Then when you run bower install the latest version of that branch is installed. That would be branch bootstrap3 of angular-ui in this example.
bower install --save package-name#master
adds this:
"dependencies": {
"package-name": "master"
}
using bower.json:
"dependencies": {
"jquery.slimscroll": "latest",
"jQuery": "1.11",
"fullPage.js": "git#github.com:overbyte/fullPage.js.git#1d6bbac3d4c3b1d3d7d4096cdbcabd1c3914393f",
}
where
"[library name - in this case a forked version of fullpage.js]" : "[from git clone box in github][#commit number if required - without this you will get latest tagged version]"

Bower does not install component

Here's the command I run
c:\projectname\www>bower install jquery --save
bower cloning git://github.com/components/jquery.git
bower cached git://github.com/components/jquery.git
bower fetching jquery
bower checking out jquery#1.9.1
bower copying C:\Users\jesse\AppData\Roaming\bower\cache\jquery\cf68c4c4e7507c8d20fee7b5f26709d9
bower installing jquery#1.9.1
Here's my component.json
{
"name": "projectname",
"version": "0.0.1",
"directory" : "scripts/components"
}
I expected to find something in c:\projectname\www\scripts\components but nothing appeared.
What am I doing wrong?
Also, it's worth noting that I tried running the same command before adding the directory property to my component.json file and nothing appeared in the components directory.
So it turns out that using a component.json file is not the correct thing to do.
I created a .bowerrc file with
{
"directory" : "scripts/components"
}
And it worked like a charm.

Resources