nilswg / pnpm-workspace

personal pnpm workspace study, git clone it and create workspace.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pnpm-workspace

configure my pnpm workspace.


Quick Start

# The way you choose to install pnpm depends on your environment.
$ npm install -g pnpm 

# Make sure you have PNPM installed already.
$ pnpm -v

# Use pnpm install to initialize the workspace.
$ pnpm install

# Now you can find the package "hello" installed in your workspace.
dependencies:
+ hello <- packages/hello

Settings

Create folders: apps\、packages\

 # such as react, angular, vite, next.js
 * - apps
 # such as math, utils, tools, libraries
 * - packages
@ file: pnpm-workspace.yaml

packages:
  - 'apps/**'
  - 'packages/**'

Test packages/hello

let's create a hello module in packages folder

// @file: package.json
{
  "name": "pnpm-workspace",
  "dependencies": {
    "hello": "workspace:*",  // <= your custom module can be shared to other app
}
$ node index.js
[from hello module]: hello!

Create Next App in apps folder.

Now, we create a my-next-app in apps/

cd apps
pnpx create-next-app@latest my-next-app
...

In my-next-app, all packages stored in the node_modules directory are symbolic links to pnpm packages. This means that these packages can be reused by other Next.js projects, which helps reduce disk storage usage.

About

personal pnpm workspace study, git clone it and create workspace.


Languages

Language:JavaScript 100.0%