stackblitz / tutorialkit

TutorialKit by StackBlitz - Create interactive tutorials powered by the WebContainer API
https://tutorialkit.dev
MIT License
234 stars 22 forks source link

Tried to contribute to docs, can't setup the environment #308

Closed noam-honig closed 6 days ago

noam-honig commented 1 week ago

Describe the bug

I tried adding some docs, but can't seem to get the environment working

Link to a StackBlitz project which shows the error

No response

Steps to reproduce

Tried both on windows and wsl git clone https://github.com/stackblitz/tutorialkit cd tutorialkit pnpm i cd docs npm run dev

I get on wsl:

noam@Win11:~/repos/tutorialkit/docs$ pnpm run dev
pnpm run dev

> @ dev /home/noam/repos/tutorialkit
> TUTORIALKIT_DEV=true pnpm -r --parallel --stream --filter='./packages/**' run dev

Scope: 9 of 15 workspace projects
packages/astro dev$ node ./scripts/build.js --watch
packages/react dev$ node ./scripts/build.js --watch
packages/runtime dev$ pnpm run build --watch --preserveWatchOutput
packages/template dev$ astro dev
packages/theme dev$ pnpm run build --watch --preserveWatchOutput
packages/types dev$ pnpm run build --watch --preserveWatchOutput
packages/astro dev: 9:36:51 AM - Starting compilation in watch mode...
packages/react dev: 9:36:51 AM - Starting compilation in watch mode...
packages/runtime dev: > @tutorialkit/runtime@0.2.1 build /home/noam/repos/tutorialkit/packages/runtime
packages/runtime dev: > tsc -b tsconfig.build.json "--watch" "--preserveWatchOutput"
packages/theme dev: > @tutorialkit/theme@0.2.1 build /home/noam/repos/tutorialkit/packages/theme
packages/theme dev: > tsc -b "--watch" "--preserveWatchOutput"
packages/types dev: > @tutorialkit/types@0.2.1 build /home/noam/repos/tutorialkit/packages/types
packages/types dev: > tsc -b tsconfig.build.json "--watch" "--preserveWatchOutput"
packages/runtime dev: 9:36:52 AM - Starting compilation in watch mode...
packages/theme dev: 9:36:52 AM - Starting compilation in watch mode...
packages/types dev: 9:36:52 AM - Starting compilation in watch mode...
packages/template dev: 9:36:52 AM [vite] Pre-transform error: Failed to resolve entry for package "@tutorialkit/theme". The package may have incorrect main/module/exports specified in its package.json.
packages/template dev: 9:36:52 AM [vite] Error when evaluating SSR module /home/noam/repos/tutorialkit/packages/template/astro.config.ts:
packages/template dev: |- Error: Failed to resolve entry for package "@tutorialkit/theme". The package may have incorrect main/module/exports specified in its package.json.
packages/template dev:     at packageEntryFailure (file:///home/noam/repos/tutorialkit/node_modules/.pnpm/vite@5.4.2_@types+node@20.14.11/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:46541:15)
packages/template dev:     at resolvePackageEntry (file:///home/noam/repos/tutorialkit/node_modules/.pnpm/vite@5.4.2_@types+node@20.14.11/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:46538:3)
packages/template dev:     at tryNodeResolve (file:///home/noam/repos/tutorialkit/node_modules/.pnpm/vite@5.4.2_@types+node@20.14.11/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:46354:16)
packages/template dev:     at ResolveIdContext.resolveId (file:///home/noam/repos/tutorialkit/node_modules/.pnpm/vite@5.4.2_@types+node@20.14.11/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:46104:19)
packages/template dev:     at PluginContainer.resolveId (file:///home/noam/repos/tutorialkit/node_modules/.pnpm/vite@5.4.2_@types+node@20.14.11/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:48919:17)
packages/template dev:     at async TransformPluginContext.resolve (file:///home/noam/repos/tutorialkit/node_modules/.pnpm/vite@5.4.2_@types+node@20.14.11/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:49079:15)
packages/template dev:     at async normalizeUrl (file:///home/noam/repos/tutorialkit/node_modules/.pnpm/vite@5.4.2_@types+node@20.14.11/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:63929:26)
packages/template dev:     at async file:///home/noam/repos/tutorialkit/node_modules/.pnpm/vite@5.4.2_@types+node@20.14.11/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:64068:39
packages/template dev:     at async Promise.all (index 8)
packages/template dev:     at async TransformPluginContext.transform (file:///home/noam/repos/tutorialkit/node_modules/.pnpm/vite@5.4.2_@types+node@20.14.11/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:63995:7)
packages/template dev: [astro] Unable to load your Astro config
packages/template dev: Failed to resolve entry for package "@tutorialkit/theme". The package may have incorrect main/module/exports specified in its package.json.
packages/template dev:   Stack trace:
packages/template dev:     at packageEntryFailure (file:///home/noam/repos/tutorialkit/node_modules/.pnpm/vite@5.4.2_@types+node@20.14.11/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:46541:15)
packages/template dev:     at tryNodeResolve (file:///home/noam/repos/tutorialkit/node_modules/.pnpm/vite@5.4.2_@types+node@20.14.11/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:46354:16)
packages/template dev:     at PluginContainer.resolveId (file:///home/noam/repos/tutorialkit/node_modules/.pnpm/vite@5.4.2_@types+node@20.14.11/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:48919:17)
packages/template dev:     at async normalizeUrl (file:///home/noam/repos/tutorialkit/node_modules/.pnpm/vite@5.4.2_@types+node@20.14.11/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:63929:26)
packages/template dev:     at async Promise.all (index 8)
packages/template dev: Failed
/home/noam/repos/tutorialkit/packages/template:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  tutorialkit-starter@0.0.1 dev: `astro dev`
Exit status 1
 ELIFECYCLE  Command failed with exit code 1.
noam@Win11:~/repos/tutorialkit/docs$

And on windows:

C:\repos\tutorialkit\docs\tutorialkit.dev>npm run dev

> tutorialkit.dev@0.0.1 dev
> astro dev

node:internal/modules/esm/resolve:304
  return new ERR_PACKAGE_PATH_NOT_EXPORTED(
         ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in C:\repos\tutorialkit\docs\tutorialkit.dev\node_modules\@tutorialkit\theme\package.json
    at exportsNotFound (node:internal/modules/esm/resolve:304:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:594:13)
    at resolveExports (node:internal/modules/cjs/loader:592:36)
    at Module._findPath (node:internal/modules/cjs/loader:669:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1131:27)
    at Function.resolve (node:internal/modules/helpers:190:19)
    at _resolve (C:\repos\tutorialkit\node_modules\.pnpm\jiti@1.21.6\node_modules\jiti\dist\jiti.js:1:241814)
    at jiti (C:\repos\tutorialkit\node_modules\.pnpm\jiti@1.21.6\node_modules\jiti\dist\jiti.js:1:244531)
    at C:/repos/tutorialkit/docs/tutorialkit.dev/uno.config.ts:1:176
    at evalModule (C:\repos\tutorialkit\node_modules\.pnpm\jiti@1.21.6\node_modules\jiti\dist\jiti.js:1:247313)
    at jiti (C:\repos\tutorialkit\node_modules\.pnpm\jiti@1.21.6\node_modules\jiti\dist\jiti.js:1:245241)
    at loadConfigFile (file:///C:/repos/tutorialkit/node_modules/.pnpm/unconfig@0.3.13/node_modules/unconfig/dist/index.mjs:177:13)
    at async Object.load (file:///C:/repos/tutorialkit/node_modules/.pnpm/unconfig@0.3.13/node_modules/unconfig/dist/index.mjs:98:24)
    at async loadConfig (file:///C:/repos/tutorialkit/node_modules/.pnpm/@unocss+config@0.59.4/node_modules/@unocss/config/dist/index.mjs:43:18)
    at async reloadConfig (file:///C:/repos/tutorialkit/node_modules/.pnpm/@unocss+vite@0.59.4_vite@5.4.2/node_modules/@unocss/vite/dist/index.mjs:93:20) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Node.js v20.14.0

C:\repos\tutorialkit\docs\tutorialkit.dev>

Expected behavior

Wanted it to work :)

p.s. It also required me to install a specific version of pnpm - 8.15.6 - otherwise pnpm i failed (at least on windows)

Screenshots

No response

Platform

Additional context

No response

AriPerkkio commented 1 week ago

Tried both on windows and wsl git clone https://github.com/stackblitz/tutorialkit cd tutorialkit pnpm i cd docs npm run dev

Does it work if you build the sources before running dev?

https://github.com/stackblitz/tutorialkit/blob/d14c4045ad692a45b5b388bb4cfcca9762e6142c/CONTRIBUTING.md?plain=1#L18-L22

noam-honig commented 1 week ago

On windows it doesn't (the build fails for rm) but on wsl it does and that's good enough

Appologies for missing that step

AriPerkkio commented 1 week ago

On windows it doesn't (the build fails for rm)

Where is this failing rm happening?

noam-honig commented 1 week ago

On windows it doesn't (the build fails for rm)

Where is this failing rm happening?

C:\repos\tutorialkit>pnpm build

> @ build C:\repos\tutorialkit
> pnpm run --stream --filter='@tutorialkit/*' --filter=create-tutorial build

Scope: 7 of 15 workspace projects
packages/types build$ tsc -b tsconfig.build.json
packages/cli build$ node scripts/build.js
packages/create-tutorial build$ rm -rf dist && tsc -b
packages/theme build$ tsc -b
packages/create-tutorial build: 'rm' is not recognized as an internal or external command,
packages/create-tutorial build: operable program or batch file.
packages/create-tutorial build: command not found: rm
packages/create-tutorial build: Failed
C:\repos\tutorialkit\packages\create-tutorial:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  create-tutorial@0.0.3 build: `rm -rf dist && tsc -b`
Exit status 127
packages/cli build: Done
 ELIFECYCLE  Command failed with exit code 127.
AriPerkkio commented 1 week ago

Oh Windows 🙃

I guess we could change that to inline node -e call. Or create separate script for this. I'd like to avoid adding rimraf.

  "scripts": {
-    "build": "rm -rf dist && tsc -b",
+    "build": "node --eval 'fs.rmSync(`./dist`, { recursive: true, force: true })' dist && tsc -b",