How to not add caret ^ sign to package installed with yarn?

Viewed 4352

I saw a solution for npm to change version prefix https://docs.npmjs.com/misc/config#save-prefix. What's the solution for yarn to not add caret?

I'd like to configure it not globally, but only for current project, if possible.

So, when I run something like yarn add --dev webpack, it saves its version as "webpack": "3.6.0", not "webpack": "^3.6.0".

4 Answers

You can do

$ yarn config set save-prefix false

or

$ echo save-prefix false >> .yarnrc

https://yarnpkg.com/lang/en/docs/cli/config/


Edit

setting the value to false will install packages like this "some-package": "false3.0.4", which can be a bit misleading. If you don't want a prefix at all then set it to an empty string via yarn config set save-prefix ""

As it is not mentioned in @Noel's answer, you can run this if you don't want to do yarn config ... and don't want to have false prefix:

echo save-prefix \"\" >> .yarnrc

It puts the following in .yarnrc:

save-prefix ""

which installs packages for the current project without any prefix.

Note: "" means empty string, i.e. put nothing as a prefix.

Related