analogjs / analog

The fullstack meta-framework for Angular. Powered by Vite and Nitro
https://analogjs.org
MIT License
2.58k stars 247 forks source link

Error when running `pnpm run build` on fresh project #982

Closed dalenguyen closed 7 months ago

dalenguyen commented 7 months ago

Please provide the environment you discovered this bug in.

Local machine

pnpm v8.15.4
Angular 17 template

Which area/package is the issue in?

create-analog

Description

When creating a new project from scratch and running the build process. There are errors in the terminal.

pnpm create analog

Please provide the exception or error you saw

Dales-MacBook-Pro-2:analog-project dalenguyen$ pnpm run build
npm run build

> analog-project@0.0.0 build /Users/dalenguyen/projects/github/analog-project
> ng build

vite v5.2.7 building for production...
TypeError: Cannot read properties of undefined (reading 'addWatchFile')
TypeError: Cannot read properties of undefined (reading 'addWatchFile')
✓ 338 modules transformed.
dist/client/index.html                             0.49 kB │ gzip:  0.31 kB
dist/client/assets/favicon-BYy3mmNz.ico            0.95 kB
dist/client/assets/index-CTeTXu9h.css              6.20 kB │ gzip:  1.88 kB
dist/client/assets/index.page-D1fJvSQP.js          0.96 kB │ gzip:  0.60 kB
dist/client/assets/analogjs-content-Cb2aAZAr.js  138.84 kB │ gzip: 44.94 kB
dist/client/assets/index-BE1TERfh.js             269.39 kB │ gzip: 84.98 kB
✓ built in 12.81s
Building SSR application...
vite v5.2.7 building SSR bundle for production...
TypeError: Cannot read properties of undefined (reading 'addWatchFile')
TypeError: Cannot read properties of undefined (reading 'addWatchFile')
TypeError: Cannot read properties of undefined (reading 'addWatchFile')
TypeError: Cannot read properties of undefined (reading 'addWatchFile')
✓ 31 modules transformed.
dist/ssr/assets/index.page-Di9OCjWC.js            2.13 kB
dist/ssr/assets/analogjs-content-Bd5qOT4v.js     19.03 kB
dist/ssr/assets/xhr2-CDOpgsGh.js                 36.45 kB
dist/ssr/main.server.js                       1,365.09 kB
✓ built in 10.46s
Prerendering static pages...
Building Server...
TypeError: The URL must be of scheme file
    at new NodeError (node:internal/errors:405:5)
    at fileURLToPath (node:internal/url:1436:11)
    at fileURLToPath (file:///Users/dalenguyen/projects/github/analog-project/node_modules/.pnpm/mlly@1.6.1/node_modules/mlly/dist/index.mjs:1976:25)
    at pathToFileURL (file:///Users/dalenguyen/projects/github/analog-project/node_modules/.pnpm/mlly@1.6.1/node_modules/mlly/dist/index.mjs:1979:26)
    at _resolve (file:///Users/dalenguyen/projects/github/analog-project/node_modules/.pnpm/mlly@1.6.1/node_modules/mlly/dist/index.mjs:2113:10)
    at resolveSync (file:///Users/dalenguyen/projects/github/analog-project/node_modules/.pnpm/mlly@1.6.1/node_modules/mlly/dist/index.mjs:2116:10)
    at resolvePathSync (file:///Users/dalenguyen/projects/github/analog-project/node_modules/.pnpm/mlly@1.6.1/node_modules/mlly/dist/index.mjs:2126:24)
    at resolvePath (file:///Users/dalenguyen/projects/github/analog-project/node_modules/.pnpm/mlly@1.6.1/node_modules/mlly/dist/index.mjs:2130:28)
    at _resolve (file:///Users/dalenguyen/projects/github/analog-project/node_modules/.pnpm/nitropack@2.9.5/node_modules/nitropack/dist/nitro.mjs:421:22)
    at Object.resolveId (file:///Users/dalenguyen/projects/github/analog-project/node_modules/.pnpm/nitropack@2.9.5/node_modules/nitropack/dist/nitro.mjs:457:29) {
  code: 'ERR_INVALID_URL_SCHEME'
}
TypeError: The URL must be of scheme file
    at new NodeError (node:internal/errors:405:5)
    at fileURLToPath (node:internal/url:1436:11)
    at fileURLToPath (file:///Users/dalenguyen/projects/github/analog-project/node_modules/.pnpm/mlly@1.6.1/node_modules/mlly/dist/index.mjs:1976:25)
    at pathToFileURL (file:///Users/dalenguyen/projects/github/analog-project/node_modules/.pnpm/mlly@1.6.1/node_modules/mlly/dist/index.mjs:1979:26)
    at _resolve (file:///Users/dalenguyen/projects/github/analog-project/node_modules/.pnpm/mlly@1.6.1/node_modules/mlly/dist/index.mjs:2113:10)
    at resolveSync (file:///Users/dalenguyen/projects/github/analog-project/node_modules/.pnpm/mlly@1.6.1/node_modules/mlly/dist/index.mjs:2116:10)
    at resolvePathSync (file:///Users/dalenguyen/projects/github/analog-project/node_modules/.pnpm/mlly@1.6.1/node_modules/mlly/dist/index.mjs:2126:24)
    at resolvePath (file:///Users/dalenguyen/projects/github/analog-project/node_modules/.pnpm/mlly@1.6.1/node_modules/mlly/dist/index.mjs:2130:28)
    at _resolve (file:///Users/dalenguyen/projects/github/analog-project/node_modules/.pnpm/nitropack@2.9.5/node_modules/nitropack/dist/nitro.mjs:421:22)
    at Object.resolveId (file:///Users/dalenguyen/projects/github/analog-project/node_modules/.pnpm/nitropack@2.9.5/node_modules/nitropack/dist/nitro.mjs:457:29) {
  code: 'ERR_INVALID_URL_SCHEME'
}

The '@analogjs/platform' server has been successfully built.

Other information

No response

I would be willing to submit a PR to fix this issue

brandonroberts commented 7 months ago

Both issues have already been fixed

The addWatchFile issue was fixed here https://github.com/analogjs/analog/pull/979. This release will go out on Monday. As a workaround, pin Vite to ~5.0.0

URL scheme issue was fixed upstream in nitro and will go in the next release. As a workaround, you can pin nitropack to 2.9.4

dalenguyen commented 7 months ago

Awesome. Thanks, Brandon!