重新安装纱线问题-代码:"MODULE_NOT_FOUND" [英] Issue reinstalling yarn - code: 'MODULE_NOT_FOUND'
问题描述
- Node.js版本:14.0.0
- 操作系统:MacOS 10.15.4
- 范围(安装,代码,运行时,元数据,其他?):纱线安装
- 模块(和版本)(如果相关):internal/modules/cjs/loader.js
- Node.js Version:14.0.0
- OS: MacOS 10.15.4
- Scope (install, code, runtime, meta, other?): Yarn install
- Module (and version) (if relevant): internal/modules/cjs/loader.js
在运行任何 Yarn 命令时,我收到以下错误.这是在重新安装后并按照以下命令顺序进行的:
Upon running any Yarn command, I get the following error. This is after reinstalling and following this sequence of commands:
纱线失速:
清理纱线缓存
- 打开终端
- rm -rf node_modules yarn.lock yarn-error.log包-lock.json
- 酿造卸载--force纱线
- npm卸载-g纱线
- 纱线-v
- 哪根纱
- rm -rf〜/.yarn(可选,不推荐)
- rm -rf/usr/local/bin/yarn
- rm -rf/usr/local/bin/yarnpkg
- 哪根纱
NPM和节点卸载:
- 继续添加到终端
- 酿造卸载--force节点
- 啤酒清理
- sudo rm -rf/usr/local/{lib/node {,/.npm,_modules},bin,share/man}/{npm *,node *,man1/node *}
- sudo rm -rf/usr/local/bin/npm/usr/local/share/man/man1/node */usr/local/lib/dtrace/node.d〜/.npm〜/.node-gyp
- sudo rm -rf/opt/local/bin/node/opt/local/include/node/opt/local/lib/node_modules
- sudo rm -rf/usr/local/bin/npm/usr/local/share/man/man1/node.1/usr/local/lib/dtrace/node.d
- 酿酒医生
- brew cleanup --prune-prefix
安装:
- 同一终端
- 酿制纱线
- 酿造安装节点
- brew链接节点
- sudo chmod 776/usr/local/lib
- brew link --overwrite节点
- sudo chmod 755/usr/local/lib
- brew链接节点
- 纱线政策集版本
- n 12.13.1
11.纱线-v&&节点-v&&npm -v
然后,在安装的第9步运行yarn命令时,以下内容将出现在终端上:
Then the following appears on terminal upon running yarn command at step 9 of the install:
USER-MacBook-Pro:~ User$ yarn
internal/modules/cjs/loader.js:1017
throw err;
^
Error: Cannot find module '/Users/jlagos/.yarn/releases/yarn-1.21.1.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1014:15)
at Function.Module._load (internal/modules/cjs/loader.js:884:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: [ ]
}
有关如何恢复纱线的任何帮助吗?似乎节点正在跟踪以前的纱线版本.
Any help on how to restore Yarn? Seems like node is keeping track of a previous yarn version.
推荐答案
每当我更新yarn时,我仍然遇到相同的问题.$ PATH中可能存在的某些东西(目前尚不可见),我尚无法删除.
I keep running into the same issue whenever I update yarn as well. Something possibly in the (currently unseen) $PATH that I've yet to be able to remove.
@jlagos指出,您可以通过在该位置上复制最新版本来欺骗系统运行最新版本而不是1.21.1.
As @jlagos pointed out, you can trick the system to run the latest version instead of 1.21.1 by copying over the latest over that location.
If you have yet to install or see yarn at /.yarn/
you can install it directly following https://classic.yarnpkg.com/en/docs/install/ or
curl -o- -L https://yarnpkg.com/install.sh |bash
然后使用以下命令创建并复制文件位置:
Then create and copy of the file location with the following:
mkdir ~/.yarn/releases/
cp ~/.yarn/lib/cli.js ~/.yarn/releases/yarn-1.21.1.js
yarn --version
现在运行纱线时,它应该显示最新的状态(例如在撰写本文时为1.22.5).
When running yarn, it should now state the latest (such as 1.22.5 at the time of writing).
这篇关于重新安装纱线问题-代码:"MODULE_NOT_FOUND"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!