Install Bootstrap 5.0.0. Alpha 2 from package.json [duplicate] - npm

This question already has answers here:
How do I install package.json dependencies in the current directory using npm
(4 answers)
Closed 2 years ago.
Here's what I have in my current package.json
{
"devDependencies": {
"axios": "^0.19",
"bootstrap": "^4.5.0",
"cross-env": "^7.0",
"laravel-mix": "^5.0.1",
"lodash": "^4.17.19",
"resolve-url-loader": "^3.1.0"
}
}
But I would like to run the latest Bootstrap version, which is 5.0.0. Alpha 2. How do I indicate that according to package.json syntax?

Just install the Bootstrap version you want using npm:
npm install bootstrap#5.0.0-alpha2

EDIT: to specify bootstrap 5.0.0 Alpha 2 in your package.json do this
"bootstrap": "^5.0.0-alpha2",

Related

Create Ionic framework 4 Project

I have globally installed the latest version of Ionic CLI 4 (4.12.0) by running npm install -g ionic#4.12.0, after that, I created a new Ionic project using ionic start, I opened the project and checked my package.json file :
"dependencies": {
"#angular/common": "~9.1.6",
"#angular/core": "~9.1.6",
"#angular/forms": "~9.1.6",
"#angular/platform-browser": "~9.1.6",
"#angular/platform-browser-dynamic": "~9.1.6",
"#angular/router": "~9.1.6",
"#ionic-native/core": "^5.0.7",
"#ionic-native/splash-screen": "^5.0.0",
"#ionic-native/status-bar": "^5.0.0",
"#ionic/angular": "^5.0.0",
"rxjs": "~6.5.1",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
}
And as you can see, Ionic version installed is "5". Any suggestions to create Ionic 4 project instead of Ionic 5 project?
ionic --version: 4.12.0.
Thank you.
If you really want to use Ionic 4, you can install a specific version of any package by adding #[version] after the package name, so in your case for #ionic/angular, you need #ionic/angular#4.11.10.
In your project root, run:
npm i #ionic/angular#4.11.10
(version 4.11.10 is the LTS)
I'm working with ionic for 2 years and as I know, v5 and v4 have no difference in syntax or compatibility so you can use v5 and not worry about a thing.

How to fix "Module not found: can't resolve x"

This is for a group project, those with me put up some code on github and I cloned it. Did npm install and ran it with npm start. But this error keeps on coming:
https://i.imgur.com/ZrCoWJk.png
I've tried to delete the node_modules folder and reinstall it. Tried to do npm install --save react-router-dom.
The package.json file:
...
"history": "^4.9.0",
"node-sass": "^4.11.0",
"react": "^16.8.6",
"react-bootstrap": "^1.0.0-beta.6",
"react-dom": "^16.8.5",
"react-helmet": "^5.2.0",
"react-router": "^5.0.0",
"react-router-dom": "^5.0.0",
"react-scripts": "2.1.8",
...
Since the group have already done so much I'd expect to see the progress and not this error message :(
Fixed by finding the module folder in node_modules, deleting it, adding it again with npm install --save and then it worked as it should!
Looks like that the issue is with "history". Try change it's version.

package.json inside react-native folder

I downloaded a react-native application from a git repository. Inside it, there is a file called package.json that looks like this:
"dependencies": {
"expo": "^27.0.0",
"invariant": "^2.2.4",
"react": "16.3.1",
"react-native": "^0.55.0",
"react-native-iphone-x-helper": "^1.0.2",
"react-navigation": "link:../..",
"react-navigation-header-buttons": "^0.0.4",
"react-navigation-material-bottom-tabs": "0.1.3",
"react-navigation-tabs": "^0.5.1"
}
Do I need to use npm to install all these libraries or will the app download them automatically?
Thanks!
Yes, you need to npm install in the terminal, from the project root directory, to download and install the dependencies, as #gaback suggested in a comment.
Alternatively, if you prefer using yarn, you can yarn install from the same directory to install the dependencies.

Couldn't find preset "env" relative to directory

So far I have been unsuccessful in an attempt to use the env preset. I browsed the git issues that others have raised such as this, and implemented some of the suggestions that appeared to work for others, but no luck so far.
Here's what I'm working with:
package.json
"bundle": "browserify ./client/app.js -d -o ./public/o.js -t [ babelify --presets [ env ] ]",
"devDependencies": {
"#babel/cli": "^7.0.0-beta.40",
"#babel/preset-env": "^7.0.0-beta.40",
"babel-core": "^6.26.0",
"babelify": "^8.0.0"
...
And here is the error:
Error: Couldn't find preset "env" relative to directory "/Users/user/Documents/git/ts/client" while parsing file: /Users/user/Documents/git/ts/client/app.js
Anything I could be missing?
Many of the github issues relating to this suggest that babel-preset-env is not installed.
Indeed it doesn't seem to be there in your package.json. Add & install it by doing this:
npm install babel-preset-env --save
Though the earlier answers do provide the right solution and it works. But this should be installed as a dev dependency not as the core one. As this is needed only for development work. If you are using npm you can use:
npm install --save-dev babel-preset-env
or if you are using yarn as package manager then use:
yarn add --dev babel-preset-env
You just need to install babel-preset-env and your code will compile properly.
npm install babel-preset-env
Basically, this type of error occurs due to mismatch in versions of babel-core, babel-preset-env and babel-loader. Below are matched and tested devDependencies, which worked for me.
"devDependencies": {
"#babel/core": "^7.11.6",
"#babel/preset-env": "^7.11.5",
"babel-loader": "^8.1.0",
"html-webpack-plugin": "^4.5.0",
"install": "^0.13.0",
"npm": "^6.14.8",
"regenerator-runtime": "^0.13.7",
"webpack": "^4.44.2",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0"
},
"dependencies": {
"babel-polyfill": "^6.26.0"
}
You can check whether .babelrc file exists in the directory above or above the directory. Just delete the file is OK

NPM, package.json - how to add dependency with "#" in name

I am trying to install new Angular 2 RC in my project. Module name in NPM was changed from angular2 to #angular/core. But when I add it to my package.json, it tries to install module angular/core instead and doesn't find it. When I type
npm install #angular/core
in console, then Angular 2 is properly installed. Do you know why package.json skipps "#" in module name and how to fix it?
//Edit: I found out that it's not just a name, but "#" indicates a scoped package. Anyway, this should work using package.json (as described in documentation), but for some reason doesn't.
I am using Visual Studio 2015 with latest updates and my project is an ASP.NET MVC 6 project (which comes equipped with npm support)
You should use the package.json from Angular2 Docs:
{
"dependencies": {
"#angular/common": "2.0.0-rc.0",
"#angular/compiler": "2.0.0-rc.0",
"#angular/core": "2.0.0-rc.0",
"#angular/http": "2.0.0-rc.0",
"#angular/platform-browser": "2.0.0-rc.0",
"#angular/platform-browser-dynamic": "2.0.0-rc.0",
"#angular/router-deprecated": "2.0.0-rc.0",
"#angular/upgrade": "2.0.0-rc.0",
"systemjs": "0.19.27",
"es6-shim": "^0.35.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",
"angular2-in-memory-web-api": "0.0.5",
"bootstrap": "^3.3.6"
},
"devDependencies": {
"concurrently": "^2.0.0",
"lite-server": "^2.2.0",
"typescript": "^1.8.10",
"typings": "^0.8.1"
}
}
Then make sure and run npm install in the root directory.
Thanks #Dov Benyomin Sohacheski, I wasn't aware of this file.
But unfortunately it didn't resolve my problem. The key was my usage of Visual Studio 2015 and possible outdated version of NPM that shipped with it. I installed Node.js and configured Visual Studio to use this version instead of built-in one and it started working.
Here is a tutorial of how to make VS use our own version of GIT instead of built-in one. Steps for NPM are basically the same. One important difference is you cannot just uncheck $(DevEnvDir)\Extensions\Microsoft\Web Tools\External, because there are also other tools, so you need to add location of NPM above it.
My final configuration:
Don't forget to restart VisualStudio after that.