Skip to content
Search

Npm:Link

lastmod 2025-02-14created 2022-05-266 edits

Mainly useful for library development.

Usage

Go to the library project folder. (Assume the library name is @projectname/api)

npm link  # global symlink 생성됨.

Go to the application project folder.

npm link @projectname/api

The Global Symlink for @projectname/api created first is used.

To check that it is linked correctly, see whether the library in the node_modules folder is a symbolic link.

$ ls -la node_modules/@projectname/
total 44
drwxrwxr-x    2 yourid yourid  4096 May 26 12:22 .
drwxrwxr-x 1001 yourid yourid 36864 May 26 11:35 ..
lrwxrwxrwx    1 yourid yourid    42 May 26 12:22 api -> ../../../../../.config/yarn/link/@projectname/api

If you made custom scripts

Do not use the library project's script; use the application project's script. Taking the case above as an example, if the path of @projectname/api is /home/yourid/Project/recc/api:

Link the library project:

./yarn --cwd /home/yourid/Project/projectname/api link

INFORMATION

For reference, with npm it is npm --prefix /home/yourid/Project/projectname/api link.

Link the application project:

./yarn link @projectname/api

See also

Favorite site

author Zer0 sitemap