node.js - 在 React Native 中使用 npm install 安装 Node 模块时出现错误

标签 node.js react-native npm-install

使用npm install安装 Node 模块时出错 我安装了 xcode 和命令行工具,但构建仍然失败。

我正在向我的项目添加一个 Node 模块,但在执行 npm install 删除 Node 模块文件夹并再次执行 npm install 之前,我无法构建该项目。仅删除 Node 模块并执行 npm install 并不能解决问题。

这是错误输出:

clang: warning: using sysroot for 'iPhoneSimulator' but targeting 'MacOSX' [-Wincompatible-sysroot]
In file included from ../fsevents.cc:72:
../src/thread.cc:36:25: error: unknown type name 'ConstFSEventStreamRef'
void HandleStreamEvents(ConstFSEventStreamRef stream, void *ctx, size_t ...
                        ^
../src/thread.cc:36:108: error: unknown type name 'FSEventStreamEventFlags'
  ...stream, void *ctx, size_t numEvents, void *eventPaths, const FSEventStre...
                                                                  ^
../src/thread.cc:36:152: error: unknown type name 'FSEventStreamEventId'
  ...*eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventSt...
                                                                    ^
../src/thread.cc:54:3: error: unknown type name 'FSEventStreamContext'
  FSEventStreamContext context = { 0, ctx, NULL, NULL, NULL };
  ^
../src/thread.cc:56:3: error: unknown type name 'FSEventStreamRef'
  FSEventStreamRef stream = FSEventStreamCreate(NULL, &HandleStreamEvent...
  ^
../src/thread.cc:56:98: error: use of undeclared identifier
      'kFSEventStreamEventIdSinceNow'
  ...&HandleStreamEvents, &context, fse->paths, kFSEventStreamEventIdSinceNow...
                                                ^
6 errors generated.
make: *** [Release/obj.target/fse/fsevents.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 19.2.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/macos/Desktop/baps_yuva/node_modules/fsevents
gyp ERR! node -v v12.14.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok 

最佳答案

尝试卸载/重新安装 npm:

  • sudo npm uninstall npm -g

  • brew 安装 npm

关于node.js - 在 React Native 中使用 npm install 安装 Node 模块时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59627129/

相关文章:

ios - 如何快速显示来自API的图像?

Node.js:Winston:我可以将默认元数据添加到所有日志消息中吗

npm-install - 如何修复 Gridsome.js 中的错误?

javascript - 访问node.js文件中函数中的API,然后通过firebase部署该文件

javascript - 使用 NodeJS 按属性排序嵌套的 JSON

javascript - 如何在react Realm 中按日期查询?

android - 启动时发布 APK 崩溃 - React Native

react-native - 背面的确认/警告对话框

npm-install - 如何查看npm安装的日志?

npm - "npm install"给出错误消息 "invalid",这是什么?