OS - Linux mint
Yesterday I was unable to install the dependencies using yarn. I showed the error ENAMETOOLONG. Which was "solved" after applying this fix on the following url -
https://github.com/storybookjs/storybook/discussions/18441#:~:text=I-,have%20found%20a%20work%20around%20for%20the%20problem.%20you%20can%20move%20the%20yarn%20cache%20directory%20from%20home%20folder%20to%20somewhere%20in%20the%20root%20directory%0Ausing%20yarn%20config%20set%20cache%2Dfolder%20/path,-View%20full%20answer
TL;DR it told me that contents inside the /home directory might be encrypted. Which might be causing the following problem. and told to run the following command -
yarn config set cache-folder /path
# Setting the "cache folder" to /path. Which is outside /home
# This did not work because it is actually "cacheFolder" not "cache-folder"
so, I did the following
sudo mkdir /path
sudo chown $USER:$USER /path
yarn config set cacheFolder /path
After, which everything seemed to work fine. BUT, it only worked for the one app.
P.S. - It compiled and started dev server perfectly. Even though there wasn't any "./node_modules" folder.
In another app in the adjacent folder did not work. The dependencies seemed to install fine but it didn't start the dev server.
It shows the following error -
package.json not found in path
even though package.json is present in the current working directory.
This is solved by simply forcing yarn to use the node_modules for nodeLinker.
using command
yarn config set nodeLinker node-modules
or
in .yarnrc.yml file
nodeLinker: node-modules
The latest version of yarn (i.e. v3.3.0 right now) uses pnp as Yarn to solve the node_modules problem unveiled the Plug'n'Play strategy for Node. Yarn pnp