【问题标题】:Unable to create React typescript project无法创建 React 打字稿项目
【发布时间】:2019-10-22 09:00:58
【问题描述】:

您好,我在创建基于 typescript 的 react 项目时总是遇到以下错误,并且该项目是使用 .js 文件创建的。

我尝试重新安装 create-react-app 实用程序,但没有成功。

> node-pre-gyp ERR! Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.0.17/fse-v1.0.17-node-v57-darwin-x64.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for fsevents@1.0.17 and node@8.6.0 (node-v57 ABI) (falling back to source compile with node-gyp)    > 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:336:16)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 18.0.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/mpant/my-app/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" "--module_name=fse" "--module_path=/Users/mpant/my-app/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64"
gyp ERR! cwd /Users/mpant/my-app/node_modules/fsevents
gyp ERR! node -v v8.6.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/mpant/my-app/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node --module_name=fse --module_path=/Users/mpant/my-app/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/mpant/my-app/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:125:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:927:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Darwin 18.0.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/Users/mpant/my-app/node_modules/fsevents/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/mpant/my-app/node_modules/fsevents
node-pre-gyp ERR! node -v v8.6.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.32
node-pre-gyp ERR! not ok 

【问题讨论】:

  • 我看到 node@8.6.0 可能会更新到节点 10 ?最新的 LTS 吗?
  • 也尝试使用更新版本的 fsevents。我有npm WARN deprecated fsevents@1.0.17: Way too old
  • 那么您是否使用类似的东西来创建您的项目? npx create-react-app my-app --typescript 或者你说的是手动创建项目而不是 CLI 工具
  • 我正在使用 npx create-react-app my-app --typescript
  • 我最近遇到了一个类似的问题,node-sass 无法在 Windows 10 的节点 12 上安装,因为它找不到 python 二进制文件,错误看起来很相似,所以我试了一下 ;-)

标签: reactjs typescript create-react-app fsevents gyp


【解决方案1】:

尝试将本地 create-react-app 版本更新为 >=2.1

npm update -g create-react-app

然后使用以下命令使用 typescript 创建您的 react 应用程序。

create-react-app my-app --typescript

注意:使用npx与安装的create-react-app的全局版本有冲突。您也可以尝试清除 npm 缓存。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-30
    • 1970-01-01
    • 2021-11-08
    相关资源
    最近更新 更多