ZachHandley
ZachHandley
Explore posts from servers
CDCloudflare Developers
Created by ZachHandley on 7/25/2024 in #pages-help
string-width build error with Astro?
Hey, so I updated Astro, and now my builds are getting this error
21:54:35.444 Executing user command: bun run build
21:54:35.714 $ astro check && astro build
21:54:36.479 /opt/buildhome/repo/webserver/node_modules/ansi-align/index.js:3
21:54:36.479 const stringWidth = require('string-width')
21:54:36.479 ^
21:54:36.480
21:54:36.480 Error [ERR_REQUIRE_ESM]: require() of ES Module /opt/buildhome/repo/webserver/node_modules/string-width/index.js from /opt/buildhome/repo/webserver/node_modules/ansi-align/index.js not supported.
21:54:36.480 Instead change the require of /opt/buildhome/repo/webserver/node_modules/string-width/index.js in /opt/buildhome/repo/webserver/node_modules/ansi-align/index.js to a dynamic import() which is available in all CommonJS modules.
21:54:36.480 at Object.<anonymous> (/opt/buildhome/repo/webserver/node_modules/ansi-align/index.js:3:21) {
21:54:36.480 code: 'ERR_REQUIRE_ESM'
21:54:36.480 }
21:54:36.480
21:54:36.480 Node.js v18.17.1
21:54:36.491 error: script "build" exited with code 1 (SIGHUP)
21:54:36.493 Failed: Error while executing user command. Exited with error code: 1
21:54:36.502 Failed: build command exited with code: 1
21:54:37.494 Failed: error occurred while running build comman
21:54:35.444 Executing user command: bun run build
21:54:35.714 $ astro check && astro build
21:54:36.479 /opt/buildhome/repo/webserver/node_modules/ansi-align/index.js:3
21:54:36.479 const stringWidth = require('string-width')
21:54:36.479 ^
21:54:36.480
21:54:36.480 Error [ERR_REQUIRE_ESM]: require() of ES Module /opt/buildhome/repo/webserver/node_modules/string-width/index.js from /opt/buildhome/repo/webserver/node_modules/ansi-align/index.js not supported.
21:54:36.480 Instead change the require of /opt/buildhome/repo/webserver/node_modules/string-width/index.js in /opt/buildhome/repo/webserver/node_modules/ansi-align/index.js to a dynamic import() which is available in all CommonJS modules.
21:54:36.480 at Object.<anonymous> (/opt/buildhome/repo/webserver/node_modules/ansi-align/index.js:3:21) {
21:54:36.480 code: 'ERR_REQUIRE_ESM'
21:54:36.480 }
21:54:36.480
21:54:36.480 Node.js v18.17.1
21:54:36.491 error: script "build" exited with code 1 (SIGHUP)
21:54:36.493 Failed: Error while executing user command. Exited with error code: 1
21:54:36.502 Failed: build command exited with code: 1
21:54:37.494 Failed: error occurred while running build comman
I can't figure out why, I ran npm list string-width and this is what I got
socialaize-webserver@0.1.0 /home/zach/GitHub/socialaize/webserver
├─┬ @astrojs/check@0.8.2
│ └─┬ yargs@17.7.2
│ ├─┬ cliui@8.0.1
│ │ ├── string-width@4.2.3
│ │ └─┬ wrap-ansi@7.0.0
│ │ └── string-width@4.2.3 deduped
│ └── string-width@4.2.3
├─┬ @playform/compress@0.0.4
│ └─┬ astro@4.8.1
│ └── string-width@7.1.0
├─┬ astro@4.12.2
│ ├─┬ boxen@7.1.1
│ │ ├─┬ ansi-align@3.0.1
│ │ │ └── string-width@4.2.3
│ │ ├── string-width@5.1.2
│ │ ├─┬ widest-line@4.0.1
│ │ │ └── string-width@5.1.2
│ │ └─┬ wrap-ansi@8.1.0
│ │ └── string-width@5.1.2
│ ├─┬ ora@8.0.1
│ │ └── string-width@7.1.0
│ └── string-width@7.2.0
└─┬ tailwindcss@3.4.6
└─┬ sucrase@3.35.0
└─┬ glob@10.4.1
└─┬ jackspeak@3.3.0
└─┬ @isaacs/cliui@8.0.2
├── string-width@5.1.2
└─┬ wrap-ansi-cjs@npm:wrap-ansi@7.0.0
└── string-width@4.2.3
socialaize-webserver@0.1.0 /home/zach/GitHub/socialaize/webserver
├─┬ @astrojs/check@0.8.2
│ └─┬ yargs@17.7.2
│ ├─┬ cliui@8.0.1
│ │ ├── string-width@4.2.3
│ │ └─┬ wrap-ansi@7.0.0
│ │ └── string-width@4.2.3 deduped
│ └── string-width@4.2.3
├─┬ @playform/compress@0.0.4
│ └─┬ astro@4.8.1
│ └── string-width@7.1.0
├─┬ astro@4.12.2
│ ├─┬ boxen@7.1.1
│ │ ├─┬ ansi-align@3.0.1
│ │ │ └── string-width@4.2.3
│ │ ├── string-width@5.1.2
│ │ ├─┬ widest-line@4.0.1
│ │ │ └── string-width@5.1.2
│ │ └─┬ wrap-ansi@8.1.0
│ │ └── string-width@5.1.2
│ ├─┬ ora@8.0.1
│ │ └── string-width@7.1.0
│ └── string-width@7.2.0
└─┬ tailwindcss@3.4.6
└─┬ sucrase@3.35.0
└─┬ glob@10.4.1
└─┬ jackspeak@3.3.0
└─┬ @isaacs/cliui@8.0.2
├── string-width@5.1.2
└─┬ wrap-ansi-cjs@npm:wrap-ansi@7.0.0
└── string-width@4.2.3
Any help is appreciated
2 replies