問題描述
使用 Yarn 安裝的軟件包開始出現 sweetalert2 之類的錯誤 (packages installed with Yarn start to give error like sweetalert2)
我在 Rails 6 上工作。幾個小時前,我添加了 sweetalert2 和類似的紗線
yarn add sweetalert2
然後像導入它
import Swal from 'sweetalert2'
它工作正常,然後我切換了 github分公司 當回到原來的分支時,它開始給出類似的錯誤
找不到模塊'sweetalert2'
不確定是否錯過了什麼或發生了什麼。
UPDATE
我做了 yarn install
但它說已經是最新的 & 同樣的問題仍然存在。
yarn install v1.21.1
warning ../package.json: No license field
[1/4] Resolving packages...
success Already up‑to‑date.
Done in 0.76s.
參考解法
方法 1:
For sure, when you switch the branch, you can retry with npm install and yarn command as the code base has been changed/switched.
Try running yarn
and npm install
again.
(by Muhammad Faisal Iqbal、Milind)