Yarn install has been replaced with `add` - yarnpkg

On my Windows system I can run yarn install with no issue in my project. But during my Azure build which is running on Ubuntu-16.04 I get the following message:
error: install has been replaced with add to add new dependencies. Run "yarn add yarn build" instead.
Doing a yarn add gives this message:
error: Running this command will add the dependency to the workspace root rather than the workspace itself, which might not be what you want - if you really meant it, make it explicit by running this command again with the -W flag (or --ignore-workspace-root-check).
In my project I have multiple applications all with their own package.json file. If I'm reading the message correctly the yarn add will add all the dependencies to the root file and not in the directories where the package.json files are located.
So how do install the packages per directory/package.json file using yarn add?

Initially I added: yarn add --cwd apps/<foldername>/<foldername> to the build script. You can do this for multiple folders to initiate different builds. But just running yarn from the root also resolved all the different builds.

Related

Run script before installing packages with nodeLinker set to node-modules

I have to run a script (from my package.json file) before I run yarn install. The script sets up the configuration for a private package. In my .yarnrc.yml, I have nodeLinker: node-modules (and I want to keep it that way because I get other errors if I remove it).
The problem is that when I run yarn run myscript I have the following error:
Usage Error: Couldn't find the node_modules state file - running an install might help (findPackageLocation)
$ yarn run [--inspect] [--inspect-brk] [-T,--top-level] [-B,--binaries-only] <scriptName> ...
But I can't run install before the script since I have private packages that need the script before it gets installed.
I just switched from NPM to Yarn 3.2.0. With NPM, I was able to run the script before installing packages.

yarn berry run how to run installed packages

I see with yarn berry I get the plug'n'play feature instead of node_modules/
I couldn't find anything to suggest it supports running from installed packages.
For example with npm a workflow might be to run the installed version of webpack:
$ npm install --save-dev webpack
$ node node_modules/webpack/bin/webpack ...
A globally installed webpack might not be the same version. Worse yet, during Docker deployment, I get what's installed locally, the only node and npm are available globally. I thought I can do a preinstall script that does npm install -g yarn; yarn set version berry but then I'm not sure how to do webpack, jest, babel, etc, and the thought that I should have to install them all globally during the same preinstall hackaround seems like several steps backwards.
Is there some way to run from locally-installed packages that I'm missing?
I saw this possibly related question - Yarn Berry - Run a Node Script Directly
But the answer there seems a bit off the point - I'm not running any js, I'm trying to type in a package.json script, i.e. something that can run from the shell.
Why not just use yarn run <bin> (or simply yarn <bin>)? If you are in a repository set to use yarn berry, that will run any package bin file.
yarn node <file> will run any .js file with Plug n' Play set up. No need to install those dependencies globally, except for maybe yarn classic.
I was trying to do yarn some-bin and kept getting:
Couldn't find a script named "some-bin".
I eventually figured out it was because the package that provides some-bin is installed inside a workspace and not at the root of my project. So instead I had to run:
yarn workspace my-workspace some-bin
And that worked.

Yarn add —dev returns root warning

When I use yarn add —-dev I receive the warning “Running this command will add the dependency to the workspace root”
Which makes no sense, since the
—-dev flag is supposed to add it to only workspace
Running yarn add -dev returns the yarn version.
I’ve tried uninstalling and reinstalling yarn, but the error continues.
I can’t find any info on this problem and I don’t have any idea how to fix it, can someone provide some advice?
When you run yarn add --dev <package> is supposed to add package as development dependency. To add dependency to a specific workspace, cd to that workspace and run yarn add there.

gulp build through Gradle fails at install npm -failed for a project

We have gradle and npm installed on Linux box inside jenkins container where I am able to build through gulp build command but when I run
"gradle build"
Execution failed for task ':themes:portlet-layout:-portal-layouttpl:npmInstall'.
A problem occurred starting process 'command '/var/jenkins/workspace/Portal_RTC/liferay-workspace/build/node/node..
,I have got gradle npm installed and PATH set.I can say this running by npm --v , node --version.
I want to know what configuration I am missing to make it work.Also everytime I checked out the code I need to install modules again specially gulp else it start download from webhttp://mirrors.lax.liferay.com/nodejs.org/dist/v8.10.0/node-v8.10.0-linux-x64.tar.gz
when I define gradle-gulp plugin in build.gradle it says node is already installed. The imp things is the whole setup work on Developer machine on windows. Though they have copied node_modules folder from nodeJs home to their individual projects.
thanks

Yarn install trigger all scripts in my package.json, it is normal?

The documentation doesn't mention this specifity:
yarn install is used to install all dependencies for a project. This
is most commonly used when you have just checked out code for a
project, or when another developer on the project has added a new
dependency that you need to pick up.
Yarn install : Install all the dependencies listed within package.json in the local node_modules folder.

Resources