sondr3 / astro-html-minifier

DEPRECATED: A HTML minifier for Astro
MIT License
8 stars 0 forks source link

Error: Cannot find module './index.node' | @minify-html+node@0.10.3 #3

Closed Desttro closed 1 year ago

Desttro commented 1 year ago

Hello, I've just installed astro-html-minifier and tried to run pnpm astro build and I am getting this message:

pnpm astro build

> myproject@0.0.1 astro /Users/myuser/Developer/myproject
> astro "build"

node:internal/modules/cjs/loader:995
  const err = new Error(message);
              ^

Error: Cannot find module './index.node'
Require stack:
- /Users/myuser/Developer/myproject/node_modules/.pnpm/@minify-html+node@0.10.3/node_modules/@minify-html/node/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/Users/myuser/Developer/myproject/node_modules/.pnpm/@minify-html+node@0.10.3/node_modules/@minify-html/node/index.js:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/myuser/Developer/myproject/node_modules/.pnpm/@minify-html+node@0.10.3/node_modules/@minify-html/node/index.js'
  ]
}

Node.js v18.12.1
 ELIFECYCLE  Command failed with exit code 1.

I am using the latest versions of pnpm, astro, astro-html-minifier, nodejs lts, Also tried remove node_modules dir and pnpm-lock.yaml, but nothing helps.

sondr3 commented 1 year ago

What is the output of pnpm install --force? You should see some lines like this (note the last two lines):

❯ pnpm install --force
 WARN  using --force I sure hope you know what you are doing
Lockfile is up to date, resolution step is skipped
Packages: +778
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Downloading registry.npmjs.org/typescript/4.9.4: 11.6 MB/11.6 MB, done
Progress: resolved 778, reused 0, downloaded 778, added 778, done
node_modules/.pnpm/@minify-html+node@0.10.3/node_modules/@minify-html/node: Running postinstall script, done in 3.2s
node_modules/.pnpm/esbuild@0.15.18/node_modules/esbuild: Running postinstall script, done in 76ms
Desttro commented 1 year ago
pnpm install --force
 WARN  using --force I sure hope you know what you are doing
Lockfile is up to date, resolution step is skipped
Packages: +579
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 579, reused 558, downloaded 21, added 579, done
Done in 6.4s

That is strange. It seems like my local issue maybe, I will try to find out or try in a different environment

sondr3 commented 1 year ago

Looks like it might be related to https://github.com/pnpm/pnpm/issues/4649.

Desttro commented 1 year ago

I have just tried with yarn, but getting the same error.

  ~/Developer/myproject   main ⇡3 *3 !1 ❯ yarn install                                                                                21:04:26
Found existing alias for "yarn install". You should use: "yin"
yarn install v1.22.19
info No lockfile found.
[1/4] 🔍  Resolving packages...
warning @astrojs/image > magic-string > sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
[2/4] 🚚  Fetching packages...
warning prettier-plugin-astro@0.7.2: The engine "pnpm" appears to be invalid.
[3/4] 🔗  Linking dependencies...
warning " > tailwindcss@3.2.4" has unmet peer dependency "postcss@^8.0.9".
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
✨  Done in 57.84s.

  ~/Developer/myproject   main ⇡3 *3 !2 ?1 ❯ yarn astro build                                                                         21:06:03
Found existing alias for "yarn". You should use: "y"
yarn run v1.22.19
$ astro build
node:internal/modules/cjs/loader:995
  const err = new Error(message);
              ^

Error: Cannot find module './index.node'
Require stack:
- /Users/myuser/Developer/myproject/node_modules/@minify-html/node/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/Users/myuser/Developer/myproject/node_modules/@minify-html/node/index.js:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/myuser/Developer/myproject/node_modules/@minify-html/node/index.js'
  ]
}

Node.js v18.12.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

  ~/Developer/myproject   main ⇡3 *3 !2 ?1 ❯ yarn install --force                                                                     21:06:06
Found existing alias for "yarn install". You should use: "yin"
yarn install v1.22.19
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
warning prettier-plugin-astro@0.7.2: The engine "pnpm" appears to be invalid.
[3/4] 🔗  Linking dependencies...
warning " > tailwindcss@3.2.4" has unmet peer dependency "postcss@^8.0.9".
[4/4] 🔨  Rebuilding all packages...
success Saved lockfile.
✨  Done in 2.44s.

  ~/Developer/myproject   main ⇡3 *3 !2 ?1 ❯ yarn astro build                                                                         21:06:26
Found existing alias for "yarn". You should use: "y"
yarn run v1.22.19
$ astro build
node:internal/modules/cjs/loader:995
  const err = new Error(message);
              ^

Error: Cannot find module './index.node'
Require stack:
- /Users/myuser/Developer/myproject/node_modules/@minify-html/node/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/Users/myuser/Developer/myproject/node_modules/@minify-html/node/index.js:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/myuser/Developer/myproject/node_modules/@minify-html/node/index.js'
  ]
}

Node.js v18.12.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
sondr3 commented 1 year ago

That's really strange. What does your ~/.npmrc look like? (don't copy your NPM key if you have one)

Desttro commented 1 year ago

I have no ~/.npmrc file in my home directory. I have tried today on a Windows machine with the latest LTS NodeJS 18.3 and the latest pnpm, and it works, so it is a local problem. I will try to solve it and let you know.

PS C:\Users\myuser\Downloads\myproject> pnpm install
Lockfile is up to date, resolution step is skipped
Packages: +593
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: C:\Users\myuser\AppData\Local\pnpm\store\v3
  Virtual store is at:             node_modules/.pnpm
Downloading registry.npmjs.org/typescript/4.9.4: 11.6 MB/11.6 MB, done
Progress: resolved 593, reused 0, downloaded 593, added 593, done
node_modules/.pnpm/swiper@8.4.6/node_modules/swiper: Running postinstall script, done in 511ms
node_modules/.pnpm/sharp@0.31.3/node_modules/sharp: Running install script, done in 13.9s
node_modules/.pnpm/@minify-html+node@0.10.3/node_modules/@minify-html/node: Running postinstall script, done in 5s
node_modules/.pnpm/esbuild@0.15.18/node_modules/esbuild: Running postinstall script, done in 10.2s

dependencies:
+ @astrojs/image 0.12.1
+ @astrojs/prefetch 0.1.1
+ @astrojs/sitemap 1.0.0
+ @astrojs/tailwind 2.1.3
+ @astrojs/vercel 2.4.0
+ @cloudinary/url-gen 1.8.7
+ @fontsource/libre-baskerville 4.5.10
+ @fontsource/montserrat 4.5.14
+ @googlemaps/js-api-loader 1.15.1
+ astro 1.9.2
+ astro-compressor 0.2.2
+ astro-html-minifier 0.4.0
+ heroicons-astro 1.0.4
+ sharp 0.31.3
+ swiper 8.4.6
+ tailwindcss 3.2.4
+ vanilla-hcaptcha 1.0.1

devDependencies:
+ @tailwindcss/aspect-ratio 0.4.2
+ @tailwindcss/forms 0.5.3
+ @tailwindcss/typography 0.5.9
+ @types/google.maps 3.51.0
+ prettier 2.8.3
+ prettier-plugin-astro 0.7.2

Done in 1m 23.8s

PS C:\Users\myuser\Downloads\myproject> pnpm astro build

> myproject@0.0.1 astro C:\Users\myuser\Downloads\myproject
> astro "build"

06:01:16 [build] output target: static
06:01:16 [build] deploy adapter: @astrojs/vercel/static
06:01:16 [build] Collecting build info...
06:01:16 [build] Completed in 357ms.
06:01:16 [build] Building static entrypoints...
06:01:23 [build] Completed in 6.70s.

 building client
Completed in 2.02s.

 generating static routes
▶ src/pages/index.astro
  └─ /index.html (+202ms)
▶ src/pages/ochrana-osobnich-udaju.astro
  └─ /ochrana-osobnich-udaju/index.html (+104ms)
▶ src/pages/portfolio.astro
  └─ /portfolio/index.html (+85ms)
▶ src/pages/kontakt.astro
  └─ /kontakt/index.html (+102ms)
▶ src/pages/sluzby.astro
  └─ /sluzby/index.html (+73ms)
Completed in 1.31s.

@astrojs/sitemap: `sitemap-index.xml` is created.

astro-html-minifier: minified 5 HTML files in 73ms
astro-html-minifier: Minification finished

astro-compressor: finished gzip of 23 files in 160ms
astro-compressor: finished brotli of 23 files in 1052ms
astro-compressor: Compression finished

06:01:28 [build] 5 page(s) built in 11.56s
06:01:28 [build] Complete!
PS C:\Users\myuser\Downloads\myproject>
Desttro commented 1 year ago

I also tried to remove the pnpm store, but without success. It is my local issue, so that I will close it. Thank you for your response and help!

  ~/Developer/myproject   astrojs-images *3 !1 ❯ pnpm store path                                          07:10:25
/Users/myuser/Library/pnpm/store/v3
  ~/Dev/myproject   astrojs-images *3 !1 ❯ pnpm store path                                                07:10:37
  ~/Dev/myproject   astrojs-images *3 !1 ❯ rm -rf /Users/myuser/Library/pnpm/store/v3                       07:10:37
  ~/Dev/myproject   astrojs-images *3 !1 ❯ rm -rf node_modules/                                           07:10:50
  ~/Dev/myproject   astrojs-images *3 !1 ❯ rm -rf pnpm-lock.yaml                                          07:10:55

  ~/Dev/myproject   astrojs-images *3 !2 ❯ pnpm install                                                   07:10:58
Downloading registry.npmjs.org/typescript/4.9.4: 11.6 MB/11.6 MB, done
 WARN  deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
Packages: +594
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: /Users/myuser/Library/pnpm/store/v3
  Virtual store is at:             node_modules/.pnpm
node_modules/.pnpm/swiper@8.4.6/node_modules/swiper: Running postinstall script, done in 55ms
node_modules/.pnpm/sharp@0.31.3/node_modules/sharp: Running install script, done in 1.7s
node_modules/.pnpm/@minify-html+node@0.10.3/node_modules/@minify-html/node: Running postinstall script, done in 1s
Progress: resolved 615, reused 0, downloaded 594, added 594, done
node_modules/.pnpm/esbuild@0.15.18/node_modules/esbuild: Running postinstall script, done in 163ms

dependencies:
+ @astrojs/image 0.12.1 (0.13.0 is available)
+ @astrojs/prefetch 0.1.1
+ @astrojs/sitemap 1.0.0
+ @astrojs/tailwind 2.1.3 (3.0.0 is available)
+ @astrojs/vercel 2.4.0 (3.0.0 is available)
+ @cloudinary/url-gen 1.8.7
+ @fontsource/libre-baskerville 4.5.10
+ @fontsource/montserrat 4.5.14
+ @googlemaps/js-api-loader 1.15.1
+ astro 1.9.2 (2.0.1 is available)
+ astro-compressor 0.2.2
+ astro-html-minifier 0.4.0
+ heroicons-astro 1.0.4
+ sharp 0.31.3
+ swiper 8.4.6
+ tailwindcss 3.2.4
+ vanilla-hcaptcha 1.0.1

devDependencies:
+ @tailwindcss/aspect-ratio 0.4.2
+ @tailwindcss/forms 0.5.3
+ @tailwindcss/typography 0.5.9
+ @types/google.maps 3.51.0
+ prettier 2.8.3
+ prettier-plugin-astro 0.7.2

Done in 10.9s

  ~/Dev/myproject   astrojs-images *3 !1 ❯ pnpm astro build                                         11s  07:11:17

> myproject@0.0.1 astro /Users/myuser/Developer/myproject
> astro "build"

node:internal/modules/cjs/loader:1039
  const err = new Error(message);
              ^

Error: Cannot find module './index.node'
Require stack:
- /Users/myuser/Developer/myproject/node_modules/.pnpm/@minify-html+node@0.10.3/node_modules/@minify-html/node/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
    at Module._load (node:internal/modules/cjs/loader:885:27)
    at Module.require (node:internal/modules/cjs/loader:1105:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/Users/myuser/Developer/myproject/node_modules/.pnpm/@minify-html+node@0.10.3/node_modules/@minify-html/node/index.js:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/myuser/Developer/myproject/node_modules/.pnpm/@minify-html+node@0.10.3/node_modules/@minify-html/node/index.js'
  ]
}

Node.js v18.13.0
 ELIFECYCLE  Command failed with exit code 1.
sondr3 commented 1 year ago

Super strange, let me know when/if you figure it out.

developer239 commented 1 year ago

@sondr3 @Desttro I can't make it work with yarn or npm.

sondr3 commented 1 year ago

Windows for you too? Do you have a error message?

danhumphrey commented 1 year ago

I have exactly the same problem on my brand new macbook. This is fresh node/npm install and I get the same errors as above:

> astro dev

node:internal/modules/cjs/loader:956
  const err = new Error(message);
              ^

Error: Cannot find module './index.node'
Require stack:
- /Users/dan/projects/new-leaf/node_modules/@minify-html/node/index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/dan/projects/new-leaf/node_modules/@minify-html/node/index.js:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/dan/projects/new-leaf/node_modules/@minify-html/node/index.js'
  ]
}

Any suggestions?