When installing dependencies using yarn, one package (newrelic) gives the following error:
newrelic#5.6.2: The engine "node" is incompatible with this module. Expected version ">=6.0.0 <11.0.0". Got "11.13.0"
The only workaround to this I could find is to run
yarn install --ignore-engines
However, this would ignore engine mismatch across packages. Is there any way to ignore it only for a specific package?
There doesn't appear to be a way to provide package-specific flags on the install command.
However, you can try adding the problematic packages with the flag and followup with a normal install afterwards.
yarn add <problematic packages> --ignore-engines
yarn install
By default, unless --force is provided as a flag to yarn install, packages that already are installed will not be fetched again.
Related
In my node.js project, I had using yarn installed the dependency #nestjs/jwt, now I want to uninstall it since I am not using it.
I run yarn remove #nestjs/jwt. It was successful. I checked my package.json, it was removed. But when I check the yarn.lock file, it is still showing. Why is that?
My git add -p yarn.lock shows me:
-"#nestjs/jwt#8.0.0", "#nestjs/jwt#^8.0.0":
+"#nestjs/jwt#^8.0.0":
version "8.0.0"
resolved "https://registry.yarnpkg.com/#nestjs/jwt/-/jwt-8.0.0.tgz#6c811c17634252dd1qcd5dabf409db4692b812da"
integrity sha512-fz2LQgYY2zmuD8S+8UE215anwKyXlnB/1FwJMLVR47clNfMeFMK8WCxmn6xd0hF5JKuV1crO6FVabb1qWzDxqQ==
Besides packages you explicitly install, packages depend on other packages. To see a graph of any dependents of this package you have installed, do:
yarn why #nestjs/jwt -R
Yarn.lock is what yarn uses to know what versions of each dependency are installed so it can get those exact versions again when you run yarn install on a new machine. Try running 'yarn upgrade'. This should create a new yarn.lock file without those dependencies.
I want to install only the "devDependencies" listed in the package.json file using yarn. I use the command yarn install --production=false but it doesn't work.
Yarn doesn't support it currently (2022, v1.22). Actually neither does npm since v7. An argument against it is you most likely need the production deps to do development. For example, how you gonna test the build without the prod deps? Although seems plenty of people are asking for it - see above links.
The reverse (install only prod deps) is more common use case and is supported: yarn install --prod.
This happens when I run expo install expo-permissions
It explicitly returns me
Installing 1 SDK 35.0.0 compatible native module using Yarn.
yarn add expo-permissions#~7.0.0
spawn yarnpkg ENOENT
Set EXPO_DEBUG=true in your env to view the stack trace.
Which is strange because I don't normally use Yarn. I use NPM to install dependencies.
I know this error has to do with my files or some path not being configured correctly. What I don't know is which path it is that I have to change and how to do so.
Please let me know if there is any other relevant info that I should add here.
I had the same problem as you my solution and you perform the installation of yarn via npm:
npm i -g yarn
I believe this error is caused because he cannot find the symbolic link for yarnpkg. When executing this command, yarn will be updated and linked.
You can just pass the flag --npm after the command.
expo install [package-name] --npm
Best solution for this would be using --npm flag
Example:
expo install pkname --npm,
expo update --npm,
expo upgrade --npm,
This is happened because you haven't executed yarn install or yarn command.
Yes, I tried many ways and finally, I found the solution.
The issue was different yarn package version.
So first of all, you need to upgrade yarn version lastest.
open terminal and type the following.
npm install --global yarn
expo update
Hope this solve your issue.
I had a similar problem. You should install yarn in your system, since that's what Expo CLI is trying to execute to install packages. For me my issue was that I did had yarn but I had an old version. I had to update my yarn version to 1.19.0. If you install this version it should work correctly.
I recommend using yvm to install and manage different versions of yarn. After you install yvm it is as easy to install yarn as yvm install <version>, so in this case you would do yvm install 1.19.0. And if you ever have to change versions because another project doesn't work with 1.19.0 (sometimes it happens) you can just install another version and change between versions by doing yvm use <version>.
Hope this helps!
This worked for me:
Latest Yarn Installation (from here)
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
sudo apt update && sudo apt install --no-install-recommends yarn
Add this to your profile: export PATH="$PATH:/opt/yarn-[version]/bin" (the path may vary depending on where you extracted Yarn to)
In the terminal, log in and log out for the changes to take effect
yarn --version checks if the version is latest (1.0+).
Then expo update <version> (ex: 36.0.0)
Concideration:
Do not forget to check if you give attention to similar warning: "warning package-lock.json found. Your project contains lock files generated by tools other than Yarn."
"spawn yarnpkg ENOENT" usually indicates that the system cannot find the "yarnpkg" command.
npm i -g corepack
This worked for me.
For nextjs you can try this as I found out that I am npx not yarn same as how I start npx expo start
npx expo update
I somehow have both yarn and npm for JHipster on my Linux Mint laptop. After I do the followings
yarn global remove generator-jhipster
yarn global add generator-jhipster
There isn't a result for
which jhispter
After I run the following commands
npm uninstall -g generator-jhipster
npm install -g generator-jhipster
an old version Jhipster shows up for
which jhispter
I have done an online search on the subject, but unable to resolve this problem after trying some methods mentioned on some posts.
How to get it right?
When confused about your local setup after installing JHipster through many ways (npm, yarn, linking from the sources, ...), I have found a way that works all the time. Recent version of NodeJs come with a useful tool called npx which can download a package from npm and execute it immediately. So the trick is simply to run:
npx generator-jhipster
You can also run a specific version, for example:
npx generator-jhipster#v5.3.4
In the blog post announcing yarn (an alternative npm client) they say, "The easiest way to get started is to run npm install -g yarn". But if you go to the "install yarn" page in their docs, "npm install yarn" isn't listed on any of the platform-specific installation pages, and it's only offered as the third of three options on the "Alternatives" page. Furthermore when you npm install yarn it prints a deprecation warning, "It is recommended to install Yarn using the native installation method for your environment." So my question is if npm install is the easiest installation method, why isn't it a recommended method in their docs? Are there disadvantages to installing yarn using npm?
Edit (2020/11/23):
Thanks to #Kissaki for providing an update on Yarn's advice in the comments.
As of Yarn 2.x, the Yarn team has altered their advice and now suggests installing the tool via npm. This advice centers around the advantages of locking the version of Yarn used on a per-project basis. This allows projects to be resilient to variations between versions of Yarn.
From the new Yarn "Installation" page:
Using a single package manager across your system has always been a
problem. To be stable, installs need to be run with the same package
manager version across environments, otherwise there's a risk we
introduce accidental breaking changes between versions - after all,
that's why the concept of lockfile was introduced in the first place!
And with Yarn being in a sense your very first project dependency, it
should make sense to "lock it" as well.
For this reason, Yarn 2 and later are meant to be managed on a
by-project basis.
This is similar to other methods of locking build tool versions on a per-project basis. See the Gradle Wrapper for an example.
The advantages of a standalone Yarn installation fall apart rather quickly, particularly with the Yarn team's change in direction. Installing via npm is now suggested, and instructions for standalone installations no longer appear to be offered on their site as of Yarn 2.x.
Original Answer:
According to the Yarn project maintainers, installing Yarn via npm goes against the goals of the project, can cause issues, and is, in general, worse than platform-specific installation methods.
Advantages to recommended platform-specific installation:
The Yarn teams regards npm as insecure and unreliable. From the "Install via npm" section on Yarn's "Installation" page:
Note: Installation of Yarn via npm is generally not recommended. Installing Yarn with npm is non-deterministic, the package is not signed, and the only integrity check performed is a basic SHA1 hash, which is a security risk when installing system-wide apps.
For these reasons, it is highly recommended that you install Yarn through the installation method best suited to your operating system.
Running Yarn, which is a separate package manager utility, via npm can lead to edge-case issues (see issue 2072)
Installing via a system package manager decouples Yarn from npm, allowing you to run Yarn without npm
The system package manager typically runs regularly, keeping Yarn updated
Installing Yarn via npm is slow
Advantages to npm install -g yarn:
Quick and easy (npm install -g yarn)
Can be done in any npm environment (platform-agnostic)
Familiar paradigm and process for Node.js developers
Can be easily updated (npm update -g yarn)
A Yarn update command exists (yarn self-update) but it seems to be broken
No dependence on system package managers
Can use different versions of Yarn for different projects or different versions of Node.js via nvm
The system package manager arguments for the recommended installation tend to break down when referring to Windows, where there is no official package manager (unless you count Windows Update). Also, Windows package managers such as Chocolatey are often not configured for automatic updates.
I'm not sure that I fully agree with the Yarn team's decision on this, but they do make some fair points. The Yarn project is still young and if it is to become a replacement for npm then it wouldn't make sense to encourage npm as its primary installer.
Regardless, installations via npm seem to work just fine for now in most cases.
Sources:
npm vs system package manager explanation
Additional explanation
Short comment on the "app" vs "npm package" goal for Yarn
Issue on how to keep Windows Yarn up to date
There's no visible disadvantage to installing Yarn through npm. In fact I chose this method myself because of a few reasons:
It's clearly the easiest way to do it. npm i --global yarn and you
can literally replace npm with yarn on your console immediately.
If you're using nvm and maintaining different code projects on each NodeJS version, then you can install Yarn on one version and not have it on the other
Honestly, the only reason I can think of that it is not mentioned in the Platform Specific installs, is that npm is platform agnostic
Because npm is not platform specific and runs on almost any system it is listed as an Alternative. There is no advantage or disadvantage over the platform specific installs. The difference would be the install location but all methods expose the global yarn command to your CLI.
I would argue they listed it as "the easiest way" because most people are already very familiar with npm.
I don't use npm to install yarn because: as of May 2022, installing on ubuntu according to the official documentation of nvm and Yarn via npm breaks capistrano scripts.
bash: yarn: command not found
Yarn works in the ssh terminal session.
Detailed Description "Why does something work in my SSH session, but not in Capistrano?" https://capistranorb.com/documentation/faq/why-does-something-work-in-my-ssh-session-but-not-in-capistrano/
So I removed the default install of nvm nodejs yarn,
$ npm uninstall -g yarn
$ nvm deactivate
$ nvm uninstall 16.15.0
$ nvm unload
$ rm -r ~/.nvm
and installed yarn like this:
$ curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
$ curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
$ echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
$ sudo apt-get update && sudo apt-get install yarn
$ node -v
v16.15.0
$ npm -v
8.5.5
$ yarn -v
1.22.19
Capistrano scripts are now working.