zabumba
zabumba

Reputation: 12422

how to organize my yarn packages

I am new to Yarn (read that Bower is deprecated) and I am asking for best practices to distinguish server side libraries from WebUI browser libraries.

I am running a server.js (node.js) for which I need to install libraries for, I usually leave them in node_modules. I used to install them with npm

My webapp also has static libraries that I want to have in my assets folder.

yarn add jquery
yarn install --modules-folder assets/vendor

Now it's install all my NPM libraries into assets/vendor, but instead I only meant to have jquery in there.

How do go around that?

Is Yarn a replacement to NPM?

Upvotes: 2

Views: 610

Answers (1)

Marco Talento
Marco Talento

Reputation: 2395

First of all it's not a good practise to use NPM and Yarn... You have to choose which package manager you want to use!

They are similar, the main goal is to install/uninstall your third party dependencies. They are not replacing each other.

Read Yarn vs Npm: https://blog.risingstack.com/yarn-vs-npm-node-js-package-managers

You can also install jquery using npm install jquery --save :)

Structure your packages

If you are creating a SPA application I would recommend to separate your API and WebApp in a separate repositories.

If you want to use in the same repository, you just need to install your frontend dependencies as a normal dependency (they are all dependencies of your application)! I would recommend you to use webpack to bundle your assets from node_modules to /app/assets folder.

Upvotes: 1

Related Questions