react-native - 使用 create-react-native-app 创建新项目时出现

当我尝试使用 create-react-native-app 创建一个新项目时,出现了一个奇怪的语法错误。任何线索将不胜感激。谢谢

**create-react-native-app my-react-app**


/usr/local/lib/node_modules/create-react-native-app/build/index.js:2
module.exports=function(e,t){"use strict";var r={};function __webpack_require__(t){if(r[t]){return r[t].exports}var n=r[t]={i:t,l:false,exports:{}};e[t].call(n.exports,n,n.exports,__webpack_require__);n.l=true;return n.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(2325)}t(__webpack_require__);return startup()}({4:function(e){"use strict";e.exports=eventListenerCount;function eventListenerCount(e,t){return e.listeners(t).length}},6:function(e,t,r){"use strict";const n=r(2471);const i=r(7720);class JSONStreamError extends Error{constructor(e,t){super(e.message);Error.captureStackTrace(this,t||this.constructor)}get name(){return"JSONStreamError"}set name(e){}}const s=(e,t)=>typeof e==="string"?String(t)===e:e&&typeof e.test==="function"?e.test(t):typeof e==="boolean"||typeof e==="object"?e:typeof e==="function"?e(t):false;const o=Symbol("_parser");const a=Symbol("_onValue");const c=Symbol("_onToken

SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

最佳答案

这可能意味着您使用的是旧版本的 node 或 npm。使用以下命令升级到最新的 npm:

sudo npm install -g npm@latest

并将节点升级到最新版本(来源:https://www.geeksforgeeks.org/installation-of-node-js-on-linux/):

sudo apt install python3-software-properties software-properties-common -y
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install nodejs -y

关于react-native - 使用 create-react-native-app 创建新项目时出现语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61354610/

相关文章:

google-cloud-platform - 自托管 Gitlab,在 Google Cloud

javascript - 如何在保持背景颜色不变的情况下为 Puppeteer 生成的 pdf 页面

python - 写一个函数来乘以复数

c# - 如何使用预定义标记列表实现解析器/解释器?

c# - 了解 C# 中的非托管关键字

ios - SwiftUI View 未更新以反射(reflect) UIViewControlle

python - tf.print 何时会按预期实际工作(即打印张量和变量的值)?

linux - 如何将频率缩放驱动程序从 "intel-pstate"更改为 "acpi-cpufr

java-8 - jdk 11 中缺少外部 jar 文件

node.js - 如何增加 Node.js 中的最大调用堆栈大小