QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.86k stars 1.31k forks source link

[🐞Command "npm create qwik@latest" fails because of "SyntaxError: Unexpected token '?'" - newbie #2717

Closed P5music closed 1 year ago

P5music commented 1 year ago

Which component is affected?

Starters / CLI

Describe the bug

Hello, I discovered the qwik framework and I like it so I am trying to setup everything for developing with it. It does not seem to work on my Ubuntu 22.04 LTS system. I am a newbie as to qwik, node and to full-stack development in general. So please can you understand what is going on?

Is it an issue?

I am at the stage of creating the project. I provide what I get when using the command:

pc@pc:~/sviluppo$ npm create qwik@latest /home/pc/.npm/_npx/c458b65438bd4234/node_modules/create-qwik/index.cjs:107 ),process.exit(1)}var Kt=A(require("fs"),1),zt=require("path");var Yr=null;async function Je(){if(!Yr){let t=[],e=["app","feature","adaptor"],r=(0,zt.join)(dirname,"starters"),i=await Kt.default.promises.readdir(r);await Promise.all(i.map(async s=>{let n=s.slice(0,s.length-1);if(e.includes(n)){let o=(0,zt.join)(r,s),a=await Kt.default.promises.readdir(o);await Promise.all(a.map(async l=>{var f,d,g;let u=(0,zt.join)(o,l);if((await Kt.default.promises.stat(u)).isDirectory()){let v=await xn(u),b={id:l,name:((f=v.qwik)==null?void 0:f.displayName)??Tn(l),type:n,dir:u,pkgJson:v,docs:((d=v.qwik)==null?void 0:d.docs)??[],priority:((g=v==null?void 0:v.qwik__)==null?void 0:g.priority)??0};t.push(b)}}))}})),t.sort((s,n)=>s.priority>n.priority?-1:s.priority<n.priority?1:s.id<n.id?-1:1),Yr=t}return Yr}function On(t){t.length>0&&(console.log(\u{1F4DA} ${m.cyan("Relevant docs:")}),t.forEach(e=>{console.log(${e})})),console.log(""),console.log(\u{1F4AC} ${m.cyan("Questions? Start the conversation at:")}),console.log(" https://qwik.builder.io/chat"),console.log(" https://twitter.com/QwikDev"),console.log("")}var rl=require("path"),Ji=A(require("fs"),1);var We=A(require("fs"),1);var It=A(require("process"),1);var zr=A(require("process"),1);var jn=A(require("process"),1),Ln=A(An(),1),Fn=A(kn(),1),Vc=(0,Ln.default)(()=>{(0,Fn.default)(()=>{jn.default.stderr.write("\x1B[?25h")},{alwaysLast:!0})}),Bn=Vc;var ir=!1,Xe={};Xe.show=(t=zr.default.stderr)=>{t.isTTY&&(ir=!1,t.write("\x1B[?25h"))};Xe.hide=(t=zr.default.stderr)=>{t.isTTY&&(Bn(),ir=!0,t.write("\x1B[?25l"))};Xe.toggle=(t,e)=>{t!==void 0&&(ir=t),ir?Xe.show(e):Xe.hide(e)};var Zr=Xe;var Pt=A(Wn(),1);var U=A(require("process"),1);function vt(){return U.default.platform!=="win32"?U.default.env.TERM!=="linux":Boolean(U.default.env.CI)||Boolean(U.default.env.WT_SESSION)||Boolean(U.default.env.TERMINUS_SUBLIME)||U.default.env.ConEmuTask==="{cmd::Cmder}"||U.default.env.TERM_PROGRAM==="Terminus-Sublime"||U.default.env.TERM_PROGRAM==="vscode"||U.default.env.TERM==="xterm-256color"||U.default.env.TERM==="alacritty"||U.default.env.TERMINALEMULATOR==="JetBrains-JediTerm"}var Kc={info:m.blue("\u2139"),success:m.green("\u2714"),warning:m.yellow("\u26A0"),error:m.red("\u2716")},zc={info:m.blue("i"),success:m.green("\u221A"),warning:m.yellow("\u203C"),error:m.red("\xD7")},Zc=vt()?Kc:zc,wt=Zc;function Xr({onlyFirst:t=!1}={}){let e=["[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~]+)|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]))?\u0007)","(?:(?:\d{1,4}(?:;\d{0,4}))?[\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}function Qr(t){if(typeof t!="string")throw new TypeError(Expected a \string`, got `${typeof t}`);return t.replace(Xr(),"")}var ha=A(Qn(),1);function ti({stream:t=process.stdout}={}){return Boolean(t&&t.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}var G=A(require("process"),1),la=A(require("readline"),1),ua=A(aa(),1);var np=3,fe,Mt,it,Oe,xr=class{constructor(){$(this,fe,0);$(this,Mt,new ua.BufferListStream);$(this,it,void 0);$(this,Oe,void 0);c(this,Mt).pipe(G.default.stdout);let e=this;_(this,it,function(r,i,...s){let{stdin:n}=G.default;if(c(e,fe)>0||n.emit===c(e,it)){if(r==="keypress")return;r==="data"&&i.includes(np)&&G.default.emit("SIGINT"),Reflect.apply(c(e,it),this,[r,i,...s])}else Reflect.apply(G.default.stdin.emit,this,[r,i,...s])})}start(){bt(this,fe)._++,c(this,fe)===1&&this._realStart()}stop(){if(c(this,fe)<=0)throw new Error("stopcalled more times thanstart");bt(this,fe)._--,c(this,fe)===0&&this._realStop()}_realStart(){G.default.platform!=="win32"&&(_(this,Oe,la.default.createInterface({input:G.default.stdin,output:c(this,Mt)})),c(this,Oe).on("SIGINT",()=>{G.default.listenerCount("SIGINT")===0?G.default.emit("SIGINT"):(c(this,Oe).close(),G.default.kill(G.default.pid,"SIGINT"))}))}_realStop(){G.default.platform!=="win32"&&(c(this,Oe).close(),_(this,Oe,void 0))}};fe=new WeakMap,Mt=new WeakMap,it=new WeakMap,Oe=new WeakMap;var Sr,Re,st,Ue,de,k,te,L,He,nt,re,ie,se,ot,K,Ii=class{constructor(e){$(this,Re,0);$(this,st,!1);$(this,Ue,0);$(this,de,0);$(this,k,void 0);$(this,te,void 0);$(this,L,void 0);$(this,He,void 0);$(this,nt,void 0);$(this,re,void 0);$(this,ie,void 0);$(this,se,void 0);$(this,ot,void 0);$(this,K,void 0);fn(this,"color");Sr||(Sr=new xr),typeof e=="string"&&(e={text:e}),_(this,k,{color:"cyan",stream:It.default.stderr,discardStdin:!0,hideCursor:!0,...e}),this.color=c(this,k).color,this.spinner=c(this,k).spinner,_(this,nt,c(this,k).interval),_(this,L,c(this,k).stream),_(this,re,typeof c(this,k).isEnabled=="boolean"?c(this,k).isEnabled:ti({stream:c(this,L)})),_(this,ie,typeof c(this,k).isSilent=="boolean"?c(this,k).isSilent:!1),this.text=c(this,k).text,this.prefixText=c(this,k).prefixText,this.indent=c(this,k).indent,It.default.env.NODE_ENV==="test"&&(this._stream=c(this,L),this._isEnabled=c(this,re),Object.defineProperty(this,"_linesToClear",{get(){return c(this,Re)},set(r){_(this,Re,r)}}),Object.defineProperty(this,"_frameIndex",{get(){return c(this,de)}}),Object.defineProperty(this,"_lineCount",{get(){return c(this,Ue)}}))}get indent(){return c(this,se)}set indent(e=0){if(!(e>=0&&Number.isInteger(e)))throw new Error("Theindentoption must be an integer from 0 and up");_(this,se,e),this.updateLineCount()}get interval(){return c(this,nt)||c(this,te).interval||100}get spinner(){return c(this,te)}set spinner(e){if(_(this,de,0),_(this,nt,void 0),typeof e=="object"){if(e.frames===void 0)throw new Error("The given spinner must have aframesproperty");_(this,te,e)}else if(!vt())_(this,te,Pt.default.line);else if(e===void 0)_(this,te,Pt.default.dots);else if(e!=="default"&&Pt.default[e])_(this,te,Pt.default[e]);else throw new Error(There is no built-in spinner named '${e}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.)}get text(){return c(this,ot)}set text(e){_(this,ot,e||""),this.updateLineCount()}get prefixText(){return c(this,K)}set prefixText(e){_(this,K,e||""),this.updateLineCount()}get isSpinning(){return c(this,He)!==void 0}getFullPrefixText(e=c(this,K),r=" "){return typeof e=="string"&&e!==""?e+r:typeof e=="function"?e()+r:""}updateLineCount(){let e=c(this,L).columns||80,r=this.getFullPrefixText(c(this,K),"-");_(this,Ue,0);for(let i of Qr(" ".repeat(c(this,se))+r+"--"+c(this,ot)).split( ^

SyntaxError: Unexpected token '?' at wrapSafe (internal/modules/cjs/loader.js:915:16) at Module._compile (internal/modules/cjs/loader.js:963:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Module.require (internal/modules/cjs/loader.js:887:19) at require (internal/modules/cjs/helpers.js:74:18) at Object. (/home/pc/.npm/_npx/c458b65438bd4234/node_modules/create-qwik/create-qwik.cjs:2:20) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) npm ERR! code 1 npm ERR! path /home/pc/sviluppo npm ERR! command failed npm ERR! command sh -c create-qwik

npm ERR! A complete log of this run can be found in: npm ERR! /home/pc/.npm/_logs/2023-01-23T20_48_28_161Z-debug-0.log `

Here is the log file content

0 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'create', 'qwik@latest' ] 1 info using npm@8.5.1 2 info using node@v12.22.9 3 timing npm:load:whichnode Completed in 1ms 4 timing config:load:defaults Completed in 6ms 5 timing config:load:file:/usr/share/nodejs/npm/npmrc Completed in 13ms 6 timing config:load:builtin Completed in 14ms 7 timing config:load:cli Completed in 7ms 8 timing config:load:env Completed in 1ms 9 timing config:load:file:/home/pc/sviluppo/.npmrc Completed in 1ms 10 timing config:load:project Completed in 5ms 11 timing config:load:file:/home/pc/.npmrc Completed in 0ms 12 timing config:load:user Completed in 1ms 13 timing config:load:file:/etc/npmrc Completed in 1ms 14 timing config:load:global Completed in 1ms 15 timing config:load:validate Completed in 1ms 16 timing config:load:credentials Completed in 6ms 17 timing config:load:setEnvs Completed in 4ms 18 timing config:load Completed in 48ms 19 timing npm:load:configload Completed in 50ms 20 timing npm:load:setTitle Completed in 1ms 21 timing config:load:flatten Completed in 16ms 22 timing npm:load:display Completed in 22ms 23 verbose logfile /home/pc/.npm/_logs/2023-01-23T20_48_28_161Z-debug-0.log 24 timing npm:load:logFile Completed in 22ms 25 timing npm:load:timers Completed in 1ms 26 timing npm:load:configScope Completed in 0ms 27 timing npm:load Completed in 100ms 28 http fetch GET 200 https://registry.npmjs.org/create-qwik 1364ms (cache miss) 29 timing arborist:ctor Completed in 6ms 30 timing arborist:ctor Completed in 0ms 31 timing arborist:ctor Completed in 1ms 32 timing command:create Completed in 1883ms 33 verbose stack Error: command failed 33 verbose stack at ChildProcess.<anonymous> (/usr/share/nodejs/@npmcli/promise-spawn/index.js:64:27) 33 verbose stack at ChildProcess.emit (events.js:314:20) 33 verbose stack at maybeClose (internal/child_process.js:1022:16) 33 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5) 34 verbose cwd /home/pc/sviluppo 35 verbose Linux 5.15.0-57-generic 36 verbose argv "/usr/bin/node" "/usr/bin/npm" "create" "qwik@latest" 37 verbose node v12.22.9 38 verbose npm v8.5.1 39 error code 1 40 error path /home/pc/sviluppo 41 error command failed 42 error command sh -c create-qwik 43 verbose exit 1 44 timing npm Completed in 3166ms 45 verbose code 1 46 error A complete log of this run can be found in: 46 error /home/pc/.npm/_logs/2023-01-23T20_48_28_161Z-debug-0.log

Reproduction

https://developer.stackblitz.com/platform/webcontainers/turbo-package-manager

Steps to reproduce

npm create qwik@latest 2023-01-23T20_48_28_161Z-debug-0.log

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
    CPU: (2) x64 Intel(R) Celeron(R) CPU  N2840  @ 2.16GHz
    Memory: 1006.83 MB / 3.72 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 12.22.9 - /usr/bin/node
    npm: 8.5.1 - /usr/bin/npm
  Browsers:
    Chrome: 109.0.5414.74
    Firefox: 103.0.1

Additional Information

No response

zanettin commented 1 year ago

Hi @P5music Great to have you here 🙏 Imo it could be because of the (very) old node version you're using. Can you try to install NVM or FNM on your device. These tool would help you to install and switch between multiple node versions. After installing them try to use at least the LTS versions of node which is as of today 18.13.0 and try the steps you mentioned above. hope that helps 🤞

P5music commented 1 year ago

Hi @P5music Great to have you here pray Imo it could be because of the (very) old node version you're using. Can you try to install NVM or FNM on your device. These tool would help you to install and switch between multiple node versions. After installing them try to use at least the LTS versions of node which is as of today 18.13.0 and try the steps you mentioned above. hope that helps crossed_fingers

Hello, I was certain to follow the official instructions, like executing this command sudo apt install npm

I provided the system info in attachment, but I did not even realize that the node version is not the intended one, and it seems to be very old. I will try to set up the developing environment again, only I would say imho that such an error should be not visible, instead a message should appear saying "hey, you have an old version, your setup is wrong". It is also strange that the Ubuntu repository has such an old version.

Regards

zanettin commented 1 year ago

Thanks @P5music The provided error is not from qwik but from node itself. So unfortunately nothing we can improve on our end. Hope you get the dev env up and running 🤞