npm install material-ui does not install the latest version - javascript

I have an abandoned project which is the admin tool for a current project. This project's Material-UI version was 0.19.4. When I delete the dependency from package.json and run npm install, it installs the version "material-ui": "^0.20.2", Also when i edit my package.json, Material-UI's version by hand to version "^1.0.0" the npm crashes: No matching version found for material-ui#1.0.0. What am I missing? Why is the latest version not installed or at least the desired version? Can anyone guide me how to approach the issue?
Side note: When I run the project with the outdated Material-UI, it is not showing as the outdated version.

The newer components are now in #material-ui/core
see: https://material-ui.com/guides/migration-v0x/

npm install #material-ui/core
OR
yarn add #material-ui/core

There are some factors that may be causing the installation to fail. One that I know is maybe the version of npm is not the latest.
Try:
$ npm -g install npm
After that, try installing material-ui again.
That would work.

Related

Toastify React, error when attempting to use

When ever I attempt importing tosify into react:
Using the following:
import { ToastContainer, toast } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css';
I get the following error:
Failed to compile.
./node_modules/react-toastify/dist/react-toastify.esm.mjs
Can't import the named export 'cloneElement' from non EcmaScript module (only default export is available)
Not sure what solution is and have spent alot time trying to find solution but I am unable too, if anything else is needed let me know but when the tosify import not there the site works fine.
Try by changing the version to older version of toastify. Manually add this in your package.json file "react-toastify": "^8.1.0", , and then run npm i then again run npm start.
As stated in this bug report, this seems to be an issue that appears when react-toastify is used with older versions of react-scripts.
Your options are:
upgrade to the newest version of react-scripts (version 5 or above)
downgrade react-toastify to version 9.0.3, which seems to still work with older versions of react-scripts
All you need to do is this
npm i react-toastify#9.0.3
It seems to be some kind of error because of node version. Could you try to reproduce this with latest node version?
Don't forget to remove node_modules and yarn.lock | package-lock.json
I solved by updating my node version and react version,
npm install --save react#latest
npm install -g npm-check-updates
npm audit fix --force
I faced the same issue in React 18.2.0, which was fixed by:
#upgrading to the latest version of react-scripts
npm install react-scripts#5.0.1 # OR npm install --save react-scripts#latest
#if you encounter errors after upgrading.
rm -r node_modules
npm install
I had the same problem, I have tried to update my yarn , and react versions , but the problem was still there.
the best way is to downgrade toastify version to 8.0.0, and it will work.
use this command:
npm i react-toastify#8.0.0
or: if you are using yarn
yarn add react-toastify#8.0.0

npm install WARNs

I've tried updating npm after I did some WARNings, so I went
npm audit fix
received way more WARNs. Now when i tried installing all dependencies with
npm i
I got tons of WARN (see below). I honestly haven't got a clue what any of these mean, but did not have any before the npm fix.
Looks like you're using deprecated packages.
Try running
npm outdated
it will show you the current version, desired version, and latest version for each of your package. That won't actually do anything to your project, but it's a good first indication.
If you run
npm update
it will update each package according to what your package.json says.
For instance if you see this in your package.json
"my-package": "~1.25.0"
it means that npm update will update to (or that npm install will install) version 1.25.0 or the latest patch version such as 1.25.4.
If you see
"my-package": "^1.25.0"
it means that npm update will update to (or that npm install will install) version 1.25.0 or the latest minor or patch version such as 1.26.2.
However, npm update will not update your packages to new major versions. That means that "my-package" will not be update to 2.0.0 for instance.
I think using old version of packages can cause those kinds of warnings.
In that case, just reinstall the package to the latest version
npm uninstall my-package
npm i my-package
⚠️ But be careful as updating a package to a new major version could break your code!
My advice is to do it step by step and make sure you can always roll back in case there's a problem you don't understand!

npm install the exact package version specified in package.json

Currently, If I run npm install, it installs the updated version of already installed packages. How can I install the exact version as specified in the package.json file?
By default npm installs packages using ^ which means any version in the same major range, you can switch this behaviour by using --save-exact
// npm
npm install --save --save-exact react
// yarn
yarn add --exact react
I created a blog post about this if anyone is looking for this in the future.
https://www.dalejefferson.com/articles/2018-02-04-how-to-save-exact-npm-package-versions/
That behavior is really driven by the one specifying the versions in the package.json. If the version number looks like "1.0.0", without any other symbols, the exact version (1.0.0) should be installed.
So what you could do is simply modify the package.json and run a npm install then. Be sure to clear out the node_modules directory before you do that.
https://docs.npmjs.com/files/package.json#dependencies
You can also open package.json and change value for the package you want to remain exact. From "vue": "^2.6.10" to "vue": "2.6.10". Notice the lack of ^ sign in front of the version number.

Updating an existing package's dependency version?

I'm on Ubuntu 14.04 trying to install this package: https://www.npmjs.com/package/stanford-corenlp
However, whenever I try to do so, it tries to install node-java 0.5.5 as a dependency which fails (gives me node-gyp errors).
I looked this issue up, and it's fixed by using a newer version of node-java. 0.6.1 seems to work fine, but I don't know how to update the dependency to install the stanford-corenlp package.
add
"node-java": "^0.6.1"
in 'dependencies' of your package.json file. Then run npm install. This will install the right version of node-java.
Then try to install standford-corenlp. If they didn't hardcode the node-java version in their package.json, you should be alright

npm install specific version does not install specific version

My package.json says I have react-router: 0.13.4 installed. However, when I type in the command npm view react-router it stats that it is using version: '1.0.0-rc3
I even tried npm install react-router#0.13.4 but npm view react-router still produces version 1.0.0-rc3
I believe npm view shows details of the latest remote package release, not the installed version. Look at node_modules/react-router/package.json to see your installed version. Use the npm install react-router#0.13.4 --save command if you want to update your package.json file.
npm install react-router-dom#5.3.0
then check the version in terminal with npm view react-router-dom#5.3.0 version
it will show the version of react router.
If you look at the react-router versioning on their GitHub releases page, you will notice there is no version 0.13.4 after version 0.13.3, which might be why NPM defaults to installing the latest version 1.0.0-rc3.

Categories