简体   繁体   中英

How to install npm dependencies inside a sub directory?

I have a package.json in the root: "install": "cd packages/my-package && yarn" .

When I run yarn run install all I'm asking is that it goes into this package, installs the node_modules and dependencies and that's it. For some reason no matter what I try (yarn workspaces/lerna/manually etc.) it is installing node_modules in all packages, including the root.

WHY?! Just let me install them separately :(

Anyone knows how to easily fix this?

To move the basefolder of node_modules, you will have to create a .yarnrc file in the same directory as your package.json file. Your .yarnrc file should look like

--modules-folder packages/my-packages

The resulting output will put all of your packages after my-packages /packages/my-packages/WHERE_YOUR_PACKAGES_GO

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM