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.
Related
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.
In the browser, I get the error
Failed to compile Module not found: Can't resolve
'#material-ui/core/Container'
It's looking for the component inside of my components directory instead of node_modules. I can't change directories into node_modules ../../ because node_modules is outside of src directory and Create React App won't let me.
I've use yarn to remove and $ yarn add #material-ui/core. I've tried yarn run build which gives me the error
Cannot find module: '#material-ui/core/Container'. Make sure this
package is installed. You can install this package by running: yarn
add #material-ui/core/Container.
When I try to add it, I get the error
error Couldn't find package "#material-ui/core/Container" on the "npm"
registry.
Here's the dependencies I have that are related:
"#material-ui/core": "^3.9.3",
"#material-ui/icons": "^3.0.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
I expect to see the contents of the page not take up the full width of the screen, but instead, I receive a fail to compile error.
Container is not part of the material-ui version specified in your package.json.
To upgrade, run the following:
$ yarn add #material-ui/core#next
You might have to remove the old stable version (if that's even an option for you).
React and react-dom >= 16.8.0 are all that are needed as peer dependencies, so the experimental upgrade of material-ui should be all you need to use Container.
I had a similar issue and I resolved it by calling:
for npm:
npm install #material-ui/core
for yarn:
$ yarn add #material-ui/core#next
If you follow a npx create-react-app new-app with cd new-app and yarn add #material-ui/core it wile compile with yarn start. You might try just starting over.
However, to help your troubleshooting, this error typically happens when you try to use a Material-UI component and forget to import it. Have you tried commenting out all the code and seeing if it compiles?
This error might also indicate that there are no node_modules for what is being imported. So, npm install might solve the problem.
Just install these below packages
#emotion/react
#emotion/styled
#material-ui/core
#material-ui/icons
Just Install: npm install #material-ui/core
This problem is caused by the same material UI package you have installed, latest MUI package is written as #mui/package-name and I installed material-ui-dropzone package and this package does not adapt to new material UI name conversion means it uses the old naming conversion of MUI, for example, #material-ui/package-name
The solution for this problem will be to install core material UI and other MUI packages using the old naming conversion for example #material-ui/core or #material-ui/icons instead of #mui/core or #mui/icons
For those trying to upgrade to Material Ui v5 (MUI v5)
See this section of the migration doc to v5.
Some imports have changed name (not just the prefix)
#material-ui/core -> #mui/material
#material-ui/unstyled -> #mui/base
#material-ui/icons -> #mui/icons-material
[...]
you haven't installed Material-UI for the correct path.
step 1:
If windows-PC selects the correct path using terminal -> cd .\foldername
step2:
install Material-UI
// with npm
npm install #material-ui/core
// with yarn
yarn add #material-ui/core
I can not run the Angular 2 project.
What I tried:
- running the project by using npm install and npm start | does not work
- I cloned quickstart from the github and replaced with my src folder and I still get the "can not find module in #angular/core"
Here is the full console output: https://www.dropbox.com/s/5plmqrjd6ge0lta/error.txt?dl=0
Many people will come here. I have had the same problem. Do not panic. You are probaly following the tutorial of tutorialspoint.
Just install the core again using NPM
npm install #angular/core
There was/is a bug in certain versions of npm that causes installed modules to disappear when using npm install someModule ... or npm install someModule --save-dev
This was apparently an issue if the module being installed was from a GitHub repo and lacked a specific commit hash to reference for the installation. Although the issue was marked "closed" and the repo archived several months ago at v5.6.0, I ran into the problem today w/the latest npm 6.4.0
In my case, doing npm install rxjs completely removed the #angular/core module, along with my #ionic-native plugins, and anything else I'd installed individually (and then it failed to actually/properly install rxjs anyway!!)
Tip: copy your existing npm modules folder as a backup before starting updates or removing it entirely & trying to npm install.
You can manually install to your project via npm install #angular/core, but depending on the npm version (or the angle of the moon at that precise moment, who knows) be aware that you might wind up with other missing dependencies.
Also try npm install #angular/core && npm install ... Apparently the additional npm install helps replace the randomly deleted/missing modules in some cases.
Don't know whether this is a missing feature or I'm doing something wrong but I have the following "problem".
Lets say I want to install the foo#3.2.x package and save it automatically in my package.json
npm install foo#3.2.x -S
This would write in my package.json the version ^3.2.0
npm install foo#3.2.x -SE
This would write in my package.json the version 3.2.0
What if I want to profit of the patch versions notation and I want to have the 3.2.x in my package.json?
The only option is adding it manually?
Thanks!
The semver shorthand ~ can be used to install only patch version updates of packages but not minor or major version updates (See https://docs.npmjs.com/misc/semver#tilde-ranges-123-12-1). To make this the default in npm use npm config command
npm config set save-prefix=~
Now the tilde will be used for every package installed with
npm install foo -S
And only patch level updates are installed when using npm i.
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