nuxt / module-builder

Complete solution to build and ship Nuxt modules.
MIT License
211 stars 22 forks source link

stuck at Cleaning dist directory: `./dist` #267

Closed hanzoz closed 1 month ago

hanzoz commented 1 month ago

Hi,

I have been stuck with this error without any solution. When I tried to publish the app to my private npm repository and it got stuck when run prepack.

It's stuck at "cleaning dist directory ./dist which doesn't make sense because this script is only to remove any files in dist folder if there is a dist folder but for my case, its a brand new docker so it should have continue.

Is there any solution because I can't seems to get any further except the log below, any help will be much appreciated, thank you.

package.json

"script": {
...
"prepack": "nuxt-module-build build",
"release": "pnpm run build && pnpm publish --no-git-checks",
...
}

log from the job

`Running with gitlab-runner 15.1.0 (76984217)
  on r9 SNC7fvKv
Preparing the "docker" executor 00:06
Using Docker executor with image registry.xxx.net/base-images/node:latest ...
Pulling docker image registry.xxx.net/base-images/node:latest ...
Using docker image sha256:25429c65fa229fea8c9ad2c261289fe34917a5f605649bd8ac50619cfd2afecd for registry.xxx.net/base-images/node:latest with digest registry.xxx.net/base-images/node@sha256:5e5b70cf41538d9c34d182a8e0c5f5801b247f5cc61faaaaa65133538df174d3 ...
Preparing environment 00:02
Running on runner-snc7fvkv-project-29379-concurrent-0 via 39be3f7ff36d...
Getting source from Git repository 00:04
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /builds/name/testmodule/.git/
Checking out d55524a9 as development...
Removing module/dist/
Removing module/node_modules/
Removing nuxt3/dist/
Removing report.json
Skipping Git submodules setup
Downloading artifacts 00:03
Downloading artifacts for nuxt3_compile (4773111)...
Downloading artifacts from coordinator... ok        id=4773111 responseStatus=200 OK token=glcbt-64
Downloading artifacts for trivy (4773113)...
Downloading artifacts from coordinator... ok        id=4773113 responseStatus=200 OK token=glcbt-64
Executing "step_script" stage of the job script
Using docker image sha256:25429c65fa229fea8c9ad2c261289fe34917a5f605649bd8ac50619cfd2afecd for registry.xxx.net/base-images/node:latest with digest registry.xxx.net/base-images/node@sha256:5e5b70cf41538d9c34d182a8e0c5f5801b247f5cc61faaaaa65133538df174d3 ...
$ cd module
$ npm i -g pnpm@8.15.3
added 1 package in 2s
1 package is looking for funding
  run `npm fund` for details
$ pnpm i
Lockfile is up to date, resolution step is skipped
Progress: resolved 1, reused 0, downloaded 0, added 0
Packages: +1011
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 1011, reused 593, downloaded 0, added 0
Progress: resolved 1011, reused 1003, downloaded 0, added 743
Progress: resolved 1011, reused 1003, downloaded 0, added 1011, done
dependencies:
+ @nuxt/kit 3.11.2
devDependencies:
+ @nuxt/devtools 1.2.0
+ @nuxt/eslint-config 0.3.12
+ @nuxt/module-builder 0.6.0
+ @nuxt/schema 3.11.2
+ @nuxt/test-utils 3.12.1
+ @types/node 20.12.11
+ changelogen 0.5.5
+ eslint 9.2.0
+ nuxt 3.11.2
+ typescript 5.4.5
+ vitest 1.6.0
+ vue-tsc 2.0.16
Done in 5.9s
$ NEXUS_NPM_AUTH=$(echo -n "${CI_REPOSITORY_USER}:${CI_REPOSITORY_TOKEN}" | base64)
$ echo "//xxxxxxxx.net/repository/npm-hosted/:_auth=${NEXUS_NPM_AUTH}" >> .npmrc
$ pnpm release
> my-module@1.0.0 release /builds/ChinKX/testmodule/module
> pnpm run prepack && pnpm publish --no-git-checks
> my-module@1.0.0 prepack /builds/ChinKX/testmodule/module
> nuxt-module-build build
[info] Building my-module
[info] Cleaning dist directory: `./dist`
ManUtopiK commented 1 month ago

Same issue here.

ManUtopiK commented 1 month ago

I built a new module with : npx nuxi init -t module my-module, but still the same issue.

nuxi info:


node.js: v21.7.2 pnpm: v9.1.0


OS: NixOS 23.11.6981.27c13997bf45 (Tapir) x86_64 Host: Framework FRANBMCP0B Kernel: 6.1.90 Uptime: 2 days, 18 hours, 59 mins Packages: 2261 (nix-system), 173 (nix-user) Shell: zsh 5.9 Resolution: 2256x1504, 3440x1440 DE: GNOME 45.5 (Wayland) WM: Mutter WM Theme: Adwaita Theme: Adwaita [GTK2/3] Icons: Adwaita [GTK2/3] Terminal: tilix CPU: 11th Gen Intel i7-1165G7 (8) @ 4.700GHz GPU: Intel TigerLake-LP GT2 [Iris Xe Graphics] Memory: 21570MiB / 31897MiB

ManUtopiK commented 1 month ago

Pfff, 3 hours to found a workaround... In package.json, there is this line : "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground", I removed the nuxt-module-build build --stub && part of the command. Launch pnpm dev:prepare, re-add this command, and now pnpm prepack works.

I absolutely don't know why...

hanzoz commented 1 month ago

I add in new script prepare

"prepare": "nuxt-module-build prepare" "prepack": "nuxt-module-build build"

I try to runprepare first and then prepack in my gitlab-ci-yml

deploy_module:
  stage: deploy
  image: ${CI_REGISTRY}/base-images/node:latest
  script:
   ...
    - pnpm run prepare
    - pnpm run prepack
    - pnpm publish --no-git-checks

surprisingly it works, weird. so the "prepack": "nuxt-module-build build", somehow solve my problem and you can refer to the log below.

It's a really weird bug that prevent me from building it and deploy.

Running with gitlab-runner 15.1.0 (76984217)
  on r19 WsmDG9NS
Preparing the "docker" executor
00:04
Using Docker executor with image registry.xxx.net/base-images/node:latest ...
Pulling docker image registry.xxx.net/base-images/node:latest ...
Using docker image sha256:85cf476e4b65765f40f755dd52b2e612ed94121756b032f22bf64813987e5584 for registry.xxx.net/base-images/node:latest with digest registry.xxx.net/base-images/node@sha256:01d79cdd9cede6ab3f75367eeeabdfea99c091caf1849c99741240e4949a2dca ...
Preparing environment
00:01
Running on runner-wsmdg9ns-project-29379-concurrent-0 via 5d44f9d38ae3...
Getting source from Git repository
00:02
Fetching changes with git depth set to 20...
Initialized empty Git repository in /builds/username/testmodule/.git/
Created fresh repository.
Checking out 4c7e6272 as development...
Skipping Git submodules setup
Downloading artifacts
00:01
Downloading artifacts for nuxt3_compile (4782240)...
Downloading artifacts from coordinator... ok        id=4782240 responseStatus=200 OK token=glcbt-64
Downloading artifacts for trivy (4782242)...
Downloading artifacts from coordinator... ok        id=4782242 responseStatus=200 OK token=glcbt-64
Executing "step_script" stage of the job script
01:00
Using docker image sha256:85cf476e4b65765f40f755dd52b2e612ed94121756b032f22bf64813987e5584 for registry.xxx.net/base-images/node:latest with digest registry.xxx.net/base-images/node@sha256:01d79cdd9cede6ab3f75367eeeabdfea99c091caf1849c99741240e4949a2dca ...
$ cd module
$ npm i -g pnpm@8.15.3
added 1 package in 3s
1 package is looking for funding
  run `npm fund` for details
$ pnpm i
Lockfile is up to date, resolution step is skipped
Progress: resolved 1, reused 0, downloaded 0, added 0
Packages: +1011
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 1011, reused 0, downloaded 0, added 0
Progress: resolved 1011, reused 0, downloaded 31, added 20
Progress: resolved 1011, reused 0, downloaded 86, added 76
Progress: resolved 1011, reused 0, downloaded 155, added 144
Progress: resolved 1011, reused 0, downloaded 191, added 181
Progress: resolved 1011, reused 0, downloaded 256, added 247
Progress: resolved 1011, reused 0, downloaded 315, added 306
Progress: resolved 1011, reused 0, downloaded 390, added 382
Progress: resolved 1011, reused 0, downloaded 440, added 434
Progress: resolved 1011, reused 0, downloaded 496, added 495
Progress: resolved 1011, reused 0, downloaded 567, added 562
Progress: resolved 1011, reused 0, downloaded 630, added 628
Progress: resolved 1011, reused 0, downloaded 699, added 691
Progress: resolved 1011, reused 0, downloaded 760, added 755
Progress: resolved 1011, reused 0, downloaded 832, added 829
Progress: resolved 1011, reused 0, downloaded 906, added 901
Progress: resolved 1011, reused 0, downloaded 986, added 980
Progress: resolved 1011, reused 0, downloaded 1003, added 1011, done
.../node_modules/vue-demi postinstall$ node -e "try{require('./scripts/postinstall.js')}catch(e){}"
.../node_modules/vue-demi postinstall: Done
.../esbuild@0.20.2/node_modules/esbuild postinstall$ node install.js
.../esbuild@0.19.12/node_modules/esbuild postinstall$ node install.js
.../esbuild@0.20.2/node_modules/esbuild postinstall: Done
.../esbuild@0.19.12/node_modules/esbuild postinstall: Done
dependencies:
+ @nuxt/kit 3.11.2
devDependencies:
+ @nuxt/devtools 1.2.0
+ @nuxt/eslint-config 0.3.12
+ @nuxt/module-builder 0.6.0
+ @nuxt/schema 3.11.2
+ @nuxt/test-utils 3.12.1
+ @types/node 20.12.11
+ changelogen 0.5.5
+ eslint 9.2.0
+ nuxt 3.11.2
+ typescript 5.4.5
+ vitest 1.6.0
+ vue-tsc 2.0.16
> my-module@1.0.0 prepare /builds/username/testmodule/module
> nuxt-module-build prepare
[success] Types generated in .nuxt
Done in 27.4s
$ NEXUS_NPM_AUTH=$(echo -n "${CI_REPOSITORY_USER}:${CI_REPOSITORY_TOKEN}" | base64)
$ echo "//xxx.net/repository/npm-hosted/:_auth=${NEXUS_NPM_AUTH}" >> .npmrc
$ pnpm run prepare
> my-module@1.0.0 prepare /builds/username/testmodule/module
> nuxt-module-build prepare
[success] Types generated in .nuxt
$ pnpm run prepack
> my-module@1.0.0 prepack /builds/username/testmodule/module
> nuxt-module-build build
[info] Building my-module
[info] Cleaning dist directory: `./dist`
[success] Build succeeded for my-module
[log]   dist/runtime (total size: 293 B)
  └─ dist/runtime/plugin.mjs (141 B)
  └─ dist/runtime/plugin.d.ts (152 B)
[log]   dist/module.mjs (total size: 415 B, chunk size: 415 B, exports: default)
Σ Total dist size (byte size): 2.31 kB
[log]
$ pnpm publish --no-git-checks
> my-module@1.0.0 prepack /builds/username/testmodule/module
> nuxt-module-build build
[info] Building my-module
[info] Cleaning dist directory: `./dist`
[success] Build succeeded for my-module
[log]   dist/runtime (total size: 293 B)
  └─ dist/runtime/plugin.d.ts (152 B)
  └─ dist/runtime/plugin.mjs (141 B)
[log]   dist/module.mjs (total size: 415 B, chunk size: 415 B, exports: default)
Σ Total dist size (byte size): 2.31 kB
[log]
> my-module@1.0.0 prepare /builds/username/testmodule/module
> nuxt-module-build prepare
[success] Types generated in .nuxt
npm notice 
npm notice 📦  my-module@1.0.0
npm notice === Tarball Contents === 
npm notice 2.0kB README.md               
npm notice 227B  dist/module.cjs         
npm notice 192B  dist/module.d.mts       
npm notice 192B  dist/module.d.ts        
npm notice 154B  dist/module.json        
npm notice 415B  dist/module.mjs         
npm notice 152B  dist/runtime/plugin.d.ts
npm notice 141B  dist/runtime/plugin.mjs 
npm notice 424B  dist/types.d.mts        
npm notice 418B  dist/types.d.ts         
npm notice 1.4kB package.json            
npm notice === Tarball Details === 
npm notice name:          my-module                               
npm notice version:       1.0.0                                   
npm notice filename:      my-module-1.0.0.tgz                     
npm notice package size:  2.3 kB                                  
npm notice unpacked size: 5.7 kB                                  
npm notice shasum:        bc5771cc73cda4c49c6e59120fce9f9f3f37bc28
npm notice integrity:     sha512-UZ+I/9sO9kmX8[...]RUX8e8JX4klEA==
npm notice total files:   11                                      
npm notice 
npm notice Publishing to https://xxx.net/repository/npm-hosted/ with tag latest and default access
+ my-module@1.0.0
Cleaning up project directory and file based variables
00:02
Job succeeded

comparing to my previous attempt, I noticed that nuxt-module-build prepare run first before pnpm run prepare and then it run nuxt-module-build prepare again, which is weird

...
+ vue-tsc 2.0.16
> my-module@1.0.0 prepare /builds/username/testmodule/module
> nuxt-module-build prepare
[success] Types generated in .nuxt
Done in 27.4s
$ NEXUS_NPM_AUTH=$(echo -n "${CI_REPOSITORY_USER}:${CI_REPOSITORY_TOKEN}" | base64)
$ echo "//xxxnet/repository/npm-hosted/:_auth=${NEXUS_NPM_AUTH}" >> .npmrc
$ pnpm run prepare
> my-module@1.0.0 prepare /builds/ChinKX/testmodule/module
> nuxt-module-build prepare
[success] Types generated in .nuxt
$ pnpm run prepack
> my-module@1.0.0 prepack /builds/ChinKX/testmodule/module
> nuxt-module-build build
[info] Building my-module
[info] Cleaning dist directory: `./dist`
[success] Build succeeded for my-module
...

the log before I use nuxt-module-build prepare is as below:

+ vue-tsc 2.0.16
Done in 18.7s
$ NEXUS_NPM_AUTH=$(echo -n "${CI_REPOSITORY_USER}:${CI_REPOSITORY_TOKEN}" | base64)
$ echo "//nexus.roqs.basf.net/repository/npm-hosted/:_auth=${NEXUS_NPM_AUTH}" >> .npmrc
$ pnpm run prepack
> my-module@1.0.0 prepack /builds/ChinKX/testmodule/module
> nuxt-module-build build
[info] Building my-module
[info] Cleaning dist directory: `./dist`
FRSgit commented 1 month ago

Hey, I've investigated the issue a bit. And (at least in my project) it seems that "extends" field of my tsconfig.json was referencing a package like "extends": "@storefront-ui/typescript-config/base.json".

I've filed a PR with a fix here. But in the meantime the quick fix for your might be to use relative paths (like "extends": "./node_modules/@something/typescript-config") instead of referencing package names directly.

Hope that helps!

JiuRanYa commented 1 month ago

Same issue here.