无法在Mac OS Catalina上安装npm包(fsevents)

3

当我运行npm install express --save命令时,出现了错误。是否有人能帮助解决这个问题?

错误:

> fsevents@1.2.11 install /Users/delowar/Desktop/ytdl/node_modules/chokidar/node_modules/fsevents
> node-gyp rebuild

No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.

gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:321:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.2.0
gyp ERR! command "/usr/local/Cellar/node/13.7.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/delowar/Desktop/ytdl/node_modules/chokidar/node_modules/fsevents
gyp ERR! node -v v13.7.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok

> fsevents@1.2.11 install /Users/delowar/Desktop/ytdl/node_modules/jest-haste-map/node_modules/fsevents
> node-gyp rebuild

No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.

gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:321:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.2.0
gyp ERR! command "/usr/local/Cellar/node/13.7.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/delowar/Desktop/ytdl/node_modules/jest-haste-map/node_modules/fsevents
gyp ERR! node -v v13.7.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/chokidar/node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/jest-haste-map/node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

屏幕截图: 在此输入图片描述

https://github.com/nodejs/node-gyp/blob/HEAD/macOS_Catalina.md - Mister Jojo
问题已解决,我已分享我的解决方案。谢谢。 - Delowar Hosain
只需删除 node_modules 文件夹并重新安装包,问题就会迎刃而解。 - Asif Raza
3个回答

16

通过重新安装Xcode命令行工具解决问题。

打开终端并粘贴以下代码:

sudo rm -rf /Library/Developer/CommandLineTools

然后

xcode-select --install

注意:使用rm命令时要小心


(Note: - Be Careful using rm command)

就我所知,我不必使用“-f”选项,但我确实需要使用提升的权限“sudo”。但是该过程非常顺利! - Rockin4Life33
1
我也不得不删除 node_modules 并按照 https://dev59.com/dFIH5IYBdhLWcg3wVMWj#67919891 的建议重新安装 npm 包,以完全解决这个问题。 - Patrice Chalin

1

对我来说,上面的指令没有起作用。所以,我找到了另一种解决方案:

> xcode-select -print-path
/Library/Developer/CommandLineTools
> sudo xcode-select --reset
> xcode-select -print-path
/Applications/Xcode.app/Contents/Developer

1

我不喜欢使用rm -rf命令,因此当您在终端上安装了“trash”公式的brew时,可以选择另一种选项:

trash Library/Developer/CommandLineTools

然后

xcode-select --install

如果您没有安装垃圾桶,您可以在终端上执行以下操作: https://formulae.brew.sh/formula/trash
brew install trash

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接