qwikifiers / qwik-nx

Nx plugin for Qwik
130 stars 23 forks source link

fix: generating workspace doesn't work out of box #101

Closed intellix closed 1 year ago

intellix commented 1 year ago

Describe the bug When you go to generate a workspace using the command in README.md, it'll give constant errors

To Reproduce Steps to reproduce the behavior:

npx create-nx-workspace chat --preset=qwik-nx

if you read the error log, it'll say you didn't pass --qwikAppName so you provide that:

npx create-nx-workspace chat --preset=qwik-nx --qwikAppName=chat

The error is now essentially:

>  NX  Generating @nrwl/workspace/generators.json:new

CREATE chat/README.md
CREATE chat/.editorconfig
CREATE chat/.gitignore
CREATE chat/.prettierignore
CREATE chat/.vscode/extensions.json
CREATE chat/workspace.json
CREATE chat/package.json
CREATE chat/tools/generators/.gitkeep
CREATE chat/tools/tsconfig.tools.json
CREATE chat/tsconfig.base.json
CREATE chat/nx.json
CREATE chat/.prettierrc
CREATE chat/apps/.gitkeep
CREATE chat/libs/.gitkeep

added 381 packages, and audited 382 packages in 3s

44 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

>  NX  Generating qwik-nx:preset

 >  NX   (0 , devkit_1.ensurePackage) is not a function

   Pass --verbose to see the stacktrace.

 >  NX   Workspace creation failed, see above.

   Pass --verbose to see the stacktrace.

Expected behavior For an project to be created, ready for use

Desktop (please complete the following information):

dmitry-stepanenko commented 1 year ago

@intellix thanks for raising this. Can you please provide the content of created package.json? I have a strong feeling npx create-nx-workspace pulls an old version of Nx for you.

intellix commented 1 year ago
npx create-nx-workspace --version
14.7.13

generated package.json:

{
  "name": "my-qwik-basic-starter",
  "description": "App with Routing built-in (recommended)",
  "engines": {
    "node": ">=15.0.0"
  },
  "private": true,
  "scripts": {
    "build": "qwik build",
    "build.client": "vite build",
    "build.preview": "vite build --ssr src/entry.preview.tsx",
    "build.types": "tsc --incremental --noEmit",
    "deploy": "echo 'Run \"npm run qwik add\" to install a server adapter'",
    "dev": "vite --mode ssr",
    "dev.debug": "node --inspect-brk ./node_modules/vite/bin/vite.js --mode ssr --force",
    "fmt": "prettier --write .",
    "fmt.check": "prettier --check .",
    "lint": "eslint \"src/**/*.ts*\"",
    "preview": "qwik build preview && vite preview --open",
    "start": "vite --open --mode ssr",
    "qwik": "qwik"
  },
  "devDependencies": {
    "@builder.io/qwik": "0.21.0",
    "@builder.io/qwik-city": "0.5.3",
    "@types/eslint": "8.21.1",
    "@types/node": "^18.14.0",
    "@types/node-fetch": "latest",
    "@typescript-eslint/eslint-plugin": "5.54.0",
    "@typescript-eslint/parser": "5.54.0",
    "eslint": "8.35.0",
    "eslint-plugin-qwik": "0.21.0",
    "node-fetch": "3.3.0",
    "prettier": "2.8.4",
    "typescript": "4.9.5",
    "undici": "5.20.0",
    "vite": "4.1.4",
    "vite-tsconfig-paths": "3.5.0"
  }
}

I guess that proves it:

➜  qwik-app npx clear-npx-cache
Need to install the following packages:
  clear-npx-cache@1.0.1
Ok to proceed? (y) y
➜  qwik-app npx create-nx-workspace --version
Need to install the following packages:
  create-nx-workspace@15.8.5
Ok to proceed? (y) 
15.8.5

Sorry, I was under the impression that npx would use the latest version and only cache slightly. It works perfectly now :)