当我尝试使用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
答案 0 :(得分:0)
这可能意味着您具有旧版本的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