你能撤消 lerna 引導程序嗎? (Can you undo a lerna bootstrap?)


問題描述

你能撤消 lerna 引導程序嗎? (Can you undo a lerna bootstrap?)

我已經運行了一個 lerna bootstrap ‑‑hoist。我現在想撤消此操作並取消鏈接所有創建的符號鏈接。有命令嗎?


參考解法

方法 1:

yes, run

lerna clean

Reference: https://github.com/lerna/lerna/tree/main/commands/clean#readme

方法 2:

Lerna link (or bootstrap) will create symlinks either directly underneath a node_modules directory or, for packages with an @‑scoped name, in a subdirectory with that name. Assuming your packages are all in ./packages/*, Any symlinks directly underneath ./node_modules or in ./packages/*/node_modules. For instance, after bootstrap, lerna has created a couple symlinks to my creatively‑named @myscope/foo package:

.
├── lerna.json
├── node_modules
│   └── @myscope
│       └── foo ‑> ../../packages/foo
├── package.json
├── package‑lock.json
└── packages
    ├── bar
    │   ├── node_modules
    │   │   └── @myscope
    │   │       └── foo ‑> ../../../foo
    │   └── package.json
    └── foo
        └── package.json

I can dig those out with find:

$ find . ‑type l ‑and \( ‑path './node_modules/*' ‑or ‑path './packages/*/node_modules/*' \)
./packages/bar/node_modules/@myscope/foo
./node_modules/@myscope/foo

This isn't perfectly selective because it could find symlinks that you created with npm link.

I can use ls ‑l to dump the source and the symlink target (vs. readlink which would just print the target):

$ find . ‑type l ‑and \( ‑path './node_modules/*' ‑or ‑path './packages/*/node_modules/*' \) ‑exec ls ‑l {} \;
lrwxrwxrwx 1 eric eric 12 janv.  4 09:46 ./packages/bar/node_modules/@myscope/foo ‑> ../../../foo
lrwxrwxrwx 1 eric eric 18 janv.  4 09:45 ./node_modules/@myscope/foo ‑> ../../packages/foo

If you're feeling confident about selectivity, you can ‑exec rm {} \; to remove them. It's not as good as a built‑in undo, but at least it helps you see what lerna did.

(by SheenSebastián IturraericP)

參考文件

  1. Can you undo a lerna bootstrap? (CC BY‑SA 2.5/3.0/4.0)

#javascript #lerna #monorepo #node.js






相關問題

為什麼我不能在 IE8 (javascript) 上擴展 localStorage? (Why can't I extend localStorage on IE8 (javascript)?)

在 Javascript 中打開外部 sqlite3 數據庫 (Open external sqlite3 database in Javascript)

Javascript:數組中的所有對像都具有相同的屬性 (Javascript: All Objects in Array Have Same Properties)

為什麼我們要在 javascripts 原型中添加函數? (Why do we add functions to javascripts prototype?)

顯示 URL javascript 的最後一部分? (Display the last part of URL javascript?)

Javascript XMLHttpRequest:忽略無效的 SSL 證書 (Javascript XMLHttpRequest: Ignore invalid SSL Certificate)

有沒有辦法測試 console.log 整體 (Is there a way to test for console.log entires)

如何從 javascript 對像中獲取名稱和值到新列表中? (How to get name and values from a javascript object into a new list?)

數據未發布..幫助!html,js,firebase (Data not posting.. Help! html,js,firebase)

使用 Node.js 腳本查看表單數據 (Seeing form data with Node.js script)

使用百分比查找範圍內的值 (find the value within a range using percent)

如何通過 react.js 中的組件傳遞變量或數據? (How to pass varible or data through components in react.js?)







留言討論