30
loading...
This website collects cookies to deliver better user experience
Download full source code from KPITENG - Github
{
“private”: true,
“workspaces”: [“common“, “app”, “web”, “server”]
}
mkdir common
mkdir app
mkdir web
mkdir server
cd common
yarn init -y
cd server
yarn init -y
module.exports = () => {
console.log("Hello from KPITENG");
}
const commonFunction = require('common');
commonFunction();
"dependencies": {
"common": “1.0.0”
}
yarn install
> ls // It will print following folder hierarchy
common node_modules package.json server yarn.lock server
> ls node_modules // you can see common server directly inside it
common server
> node server/index.js // It will print following
Hello from KPITENG
module.exports = () => {
console.log("Welcome to KPITENG");
}
> node server/index.js // It will print following
Welcome to KPITENG
{
- "name": "common",
+ "name": "@sharecode/common",
}
{
- "name": "server",
+ "name": "@sharecode/server"
"dependencies": {
- "common": "1.0.0"
+ "@sharecode/common": "1.0.0"
}
}
- const commonFunction = require(“common”)
+ const commonFunction = require(“@sharecode/common”)
> yarn install
> node server/index.js // it will log following
Welcome to KPITENG
> mkdir packages
mv common/ packages/commom/
mv server/ packages/server/
mv app/ packages/app/
{
- "workspaces": ["common", "server"]
+ "workspaces": ["packages/**"]
}
> rm -rf node_modules
> cd packages/server
> rm -rf node_modules
> yarn install
> node packages/server/index.js // It will log following
Welcome to KPITENG
> cd packages/server
> yarn add graphql
> ls
package.json node_modules
> ls node_modules // It will show graphql dependency
@sharecode graphql
Download full source code from KPITENG - Github