Closed brandonroberts closed 1 year ago
We can also make this a zero-config deployment also, but setting the public
directory dist
and the server
directory to /.netlify/functions-internal
at the root of the project.
Nitro Netlify preset: https://github.com/unjs/nitro/blob/main/src/presets/netlify.ts#L12-L13
I can take it, I will be back from vacation on 1st August, and start working after that.
Hi @brandonroberts
I would love to contribute for this. @santoshyadavdev, Please let me know if is okay with me taking over the work.
Thanks 🙂
Actually I already worked on this, but we are getting some error
Leave it to me as of now
Actually I already worked on this, but we are getting some error
I just had hands-on with Netlify deployment for the same. Let me know if I could be helpful.
Ohh nice I will share the error with you tomorrow or Tuesday.
On Sun, 3 Sept 2023, 16:39 ArunKumar Nadikattu, @.***> wrote:
Actually I already worked on this, but we are getting some error
I just had hands-on with Netlify deployment for the same. Let me know if I could be helpful.
— Reply to this email directly, view it on GitHub https://github.com/analogjs/analog/issues/492#issuecomment-1704322950, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC27EB32LZ2BFLIGELV5KUTXYSJBPANCNFSM6AAAAAAZZ4RGS4 . You are receiving this because you were mentioned.Message ID: @.***>
Hi @santoshyadavdev, Any luck with the error.
Also, I would like to work on #631 , in case if you are not working on the same.
here is the error and the repo https://github.com/santoshyadavdev/analog-netlify
Both issues are related, we tried using netlify preset
Since serverDir path starts with /
, it is refereing to root of the netlify container.
But we actually need it like /opt/build/repo/.netlify/functions-internal
.
By removing the slash, the build works fine.
However in this case, the nitro output is getting built to src/server
path.
Ahh thank you so much I will try and raise a PR thank you for your help
I changed the path to try out something else as it was not working.
This works perfectly: serverDir: '{{ rootDir }}/.netlify/functions-internal',
Thank you @Aru-Ku looks like everything worked, but netlify function is throwing an error
You need to set the output format to esm for import.meta to work correctly.
@brandonroberts I think we generate esm output right?
9:59:38 PM: build-image version: 73f16e520fdddf409be6f578c8c2c8941bdf32d3 (focal)
9:59:38 PM: buildbot version: a11acbb405af91d225b392f15bc00822dbffb366
9:59:38 PM: Fetching cached dependencies
9:59:38 PM: Failed to fetch cache, continuing with build
9:59:38 PM: Starting to prepare the repo for build
9:59:38 PM: No cached dependencies found. Cloning fresh repo
9:59:38 PM: git clone --filter=blob:none https://github.com/santoshyadavdev/analog-netlify
9:59:39 PM: Preparing Git Reference refs/heads/main
9:59:40 PM: Starting to install dependencies
9:59:40 PM: Python version set to 3.8
9:59:40 PM: Attempting Ruby version 2.7.2, read from environment
9:59:41 PM: Using Ruby version 2.7.2
9:59:41 PM: Started restoring cached go cache
9:59:41 PM: Finished restoring cached go cache
9:59:41 PM: go version go1.19.12 linux/amd64
9:59:42 PM: Using PHP version 8.0
9:59:43 PM: v18.17.1 is already installed.
9:59:43 PM: Now using node v18.17.1 (npm v9.6.7)
9:59:43 PM: Enabling Node.js Corepack
9:59:44 PM: Started restoring cached build plugins
9:59:44 PM: Finished restoring cached build plugins
9:59:44 PM: Started restoring cached corepack dependencies
9:59:44 PM: Finished restoring cached corepack dependencies
9:59:44 PM: No npm workspaces detected
9:59:44 PM: Started restoring cached node modules
9:59:44 PM: Finished restoring cached node modules
9:59:44 PM: Installing npm packages using npm version 9.6.7
9:59:48 PM: npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
10:00:01 PM: added 1723 packages, and audited 1724 packages in 17s
10:00:01 PM: 206 packages are looking for funding
10:00:01 PM: run npm fund
for details
10:00:01 PM: 1 moderate severity vulnerability
10:00:01 PM: To address all issues, run:
10:00:01 PM: npm audit fix
10:00:01 PM: Run npm audit
for details.
10:00:01 PM: npm packages installed
10:00:01 PM: Install dependencies script success
10:00:01 PM: Starting build script
10:00:02 PM: Detected 2 framework(s)
10:00:02 PM: angular at version 16.1.8
10:00:02 PM: vite at version 4.4.9
10:00:02 PM: Section completed: initializing
10:00:04 PM:
10:00:04 PM: Netlify Build
10:00:04 PM: ────────────────────────────────────────────────────────────────
10:00:04 PM:
10:00:04 PM: ❯ Version
10:00:04 PM: @netlify/build 29.20.12
10:00:04 PM:
10:00:04 PM: ❯ Flags
10:00:04 PM: baseRelDir: true
10:00:04 PM: buildId: 64ff719c03df960008bade59
10:00:04 PM: deployId: 64ff719c03df960008bade5b
10:00:04 PM:
10:00:04 PM: ❯ Current directory
10:00:04 PM: /opt/build/repo
10:00:04 PM:
10:00:04 PM: ❯ Config file
10:00:04 PM: No config file was defined: using default values.
10:00:04 PM:
10:00:04 PM: ❯ Context
10:00:04 PM: production
10:00:04 PM:
10:00:04 PM: Build command from Netlify app
10:00:04 PM: ────────────────────────────────────────────────────────────────
10:00:04 PM:
10:00:04 PM: $ npm run build
10:00:04 PM: > analog-project@0.0.0 build
10:00:04 PM: > ng build
10:00:07 PM: vite v4.4.9 building for production...
10:00:08 PM: transforming...
10:00:14 PM: ✓ 341 modules transformed.
10:00:14 PM: rendering chunks...
10:00:14 PM: computing gzip size...
10:00:14 PM: dist/client/index.html 1.75 kB │ gzip: 1.31 kB
10:00:14 PM: dist/client/assets/index-05bc7378.css 5.95 kB │ gzip: 1.86 kB
10:00:14 PM: dist/client/assets/index.page-826e1922.js 1.31 kB │ gzip: 0.73 kB
10:00:14 PM: dist/client/assets/analogjs-content-6dc8669c.js 137.38 kB │ gzip: 44.53 kB
10:00:14 PM: dist/client/assets/index-2d6d4bd3.js 257.12 kB │ gzip: 81.48 kB
10:00:14 PM: Building SSR application...
10:00:14 PM: ✓ built in 7.40s
10:00:14 PM: vite v4.4.9 building SSR bundle for production...
10:00:16 PM: transforming...
10:00:22 PM: ✓ 24 modules transformed.
10:00:22 PM: rendering chunks...
10:00:22 PM: dist/ssr/assets/index.page-6d59ac18.mjs 2.48 kB
10:00:22 PM: dist/ssr/assets/analogjs-content-c1408a82.mjs 17.13 kB
10:00:22 PM: dist/ssr/main.server.mjs 1,282.56 kB
10:00:22 PM: ✓ built in 7.93s
10:00:22 PM: Building Server...
10:00:32 PM: The '@analogjs/platform' server has been successfully built.
10:00:33 PM:
10:00:33 PM: (build.command completed in 28.7s)
10:00:33 PM:
10:00:33 PM: Functions bundling
10:00:33 PM: ────────────────────────────────────────────────────────────────
10:00:33 PM:
10:00:33 PM: Packaging Functions from .netlify/functions-internal directory:
10:00:33 PM: - index.mjs
10:00:33 PM: - server.mjs
10:00:33 PM:
10:00:33 PM: ▲ [WARNING] import.meta is not available with the cjs output format and will be empty [empty-import-meta]
10:00:33 PM: .netlify/functions-internal/index.mjs:1:29:
10:00:33 PM: 1 │ globalThis.importMeta={url:import.meta.url,env:process.env};impor...
10:00:33 PM: ╵ ~~~
10:00:33 PM: You need to set the output format to esm for import.meta to work correctly.
10:00:33 PM: ✘ [ERROR] Could not resolve file:///opt/build/repo/node_modules/node-fetch-native/dist/polyfill.mjs
10:00:33 PM: .netlify/functions-internal/index.mjs:1:69:
10:00:33 PM: 1 │ ...nv};import 'file:///opt/build/repo/node_modules/node-fetch-nativ...
╵ ~~~~~~~~~~~~~
10:00:33 PM: You can mark the path file:///opt/build/repo/node_modules/node-fetch-native/dist/polyfill.mjs as external to exclude it from the bundle, which will remove this error.
10:00:33 PM: ✘ [ERROR] Could not resolve file:///opt/build/repo/node_modules/h3/dist/index.mjs
10:00:33 PM: .netlify/functions-internal/index.mjs:3:7:
10:00:33 PM: 3 │ import 'file:///opt/build/repo/node_modules/h3/dist/index.mjs';
10:00:33 PM: ╵ ~~~~~~~~~~~
10:00:33 PM: You can mark the path file:///opt/build/repo/node_modules/h3/dist/index.mjs as external to exclude it from the bundle, which will remove this error.
10:00:33 PM: ✘ [ERROR] Could not resolve file:///opt/build/repo/node_modules/ofetch/dist/node.mjs
10:00:33 PM: .netlify/functions-internal/index.mjs:4:7:
10:00:33 PM: 4 │ import 'file:///opt/build/repo/node_modules/ofetch/dist/node.mjs';
10:00:33 PM: ╵ ~~~~~~~~~~~~~~
10:00:33 PM: You can mark the path file:///opt/build/repo/node_modules/ofetch/dist/node.mjs as external to exclude it from the bundle, which will remove this error.
10:00:33 PM: ✘ [ERROR] Could not resolve file:///opt/build/repo/node_modules/destr/dist/index.mjs
10:00:33 PM: .netlify/functions-internal/index.mjs:5:7:
10:00:33 PM: 5 │ import 'file:///opt/build/repo/node_modules/destr/dist/index.mjs';
10:00:33 PM: ╵ ~~~~~~~~~~~~~~
10:00:33 PM: You can mark the path file:///opt/build/repo/node_modules/destr/dist/index.mjs as external to exclude it from the bundle, which will remove this error.
10:00:33 PM: ✘ [ERROR] Could not resolve file:///opt/build/repo/node_modules/unenv/runtime/fetch/index.mjs
10:00:33 PM: .netlify/functions-internal/index.mjs:6:7:
10:00:33 PM: 6 │ import 'file:///opt/build/repo/node_modules/unenv/runtime/fetch/ind...
╵ ~~~~~~~~~~~~
10:00:33 PM: You can mark the path file:///opt/build/repo/node_modules/unenv/runtime/fetch/index.mjs as external to exclude it from the bundle, which will remove this error.
10:00:33 PM: ✘ [ERROR] Could not resolve file:///opt/build/repo/node_modules/hookable/dist/index.mjs
10:00:33 PM: .netlify/functions-internal/index.mjs:7:7:
10:00:33 PM: 7 │ import 'file:///opt/build/repo/node_modules/hookable/dist/index.mjs';
10:00:33 PM: ╵ ~~~~~~~~~~~~~
10:00:33 PM: You can mark the path file:///opt/build/repo/node_modules/hookable/dist/index.mjs as external to exclude it from the bundle, which will remove this error.
10:00:33 PM: ✘ [ERROR] Could not resolve file:///opt/build/repo/node_modules/scule/dist/index.mjs
10:00:33 PM: .netlify/functions-internal/index.mjs:8:7:
10:00:33 PM: 8 │ import 'file:///opt/build/repo/node_modules/scule/dist/index.mjs';
10:00:33 PM: ╵ ~~~~~~~~~~~~~~
10:00:33 PM: You can mark the path file:///opt/build/repo/node_modules/scule/dist/index.mjs as external to exclude it from the bundle, which will remove this error.
10:00:33 PM: ✘ [ERROR] Could not resolve file:///opt/build/repo/node_modules/klona/dist/index.mjs
10:00:33 PM: .netlify/functions-internal/index.mjs:9:7:
10:00:33 PM: 9 │ import 'file:///opt/build/repo/node_modules/klona/dist/index.mjs';
10:00:33 PM: ╵ ~~~~~~~~~~~~~~
10:00:33 PM: You can mark the path file:///opt/build/repo/node_modules/klona/dist/index.mjs as external to exclude it from the bundle, which will remove this error.
10:00:33 PM: ✘ [ERROR] Could not resolve file:///opt/build/repo/node_modules/defu/dist/defu.mjs
10:00:33 PM: .netlify/functions-internal/index.mjs:10:7:
10:00:33 PM: 10 │ import 'file:///opt/build/repo/node_modules/defu/dist/defu.mjs';
10:00:33 PM: ╵ ~~~~~~~~~~~~
10:00:33 PM: You can mark the path file:///opt/build/repo/node_modules/defu/dist/defu.mjs as external to exclude it from the bundle, which will remove this error.
10:00:35 PM: 1 of 9 warnings and 9 of 30 errors shown (disable the message limit with --log-limit=0)
10:00:35 PM:
10:00:35 PM: Dependencies installation error
10:00:35 PM: ────────────────────────────────────────────────────────────────
10:00:35 PM:
10:00:35 PM: Error message
10:00:35 PM: A Netlify Function failed to require one of its dependencies.
10:00:35 PM: Please make sure it is present in the site's top-level package.json.
10:00:35 PM: Build failed with 30 errors:
10:00:35 PM: .netlify/functions-internal/chunks/nitro/nitro-prerenderer.mjs:1:98: ERROR: Could not resolve file:///opt/build/repo/node_modules/node-fetch-native/dist/polyfill.mjs
10:00:35 PM: .netlify/functions-internal/chunks/nitro/nitro-prerenderer.mjs:2:265: ERROR: Could not resolve file:///opt/build/repo/node_modules/h3/dist/index.mjs
10:00:35 PM: .netlify/functions-internal/chunks/nitro/nitro-prerenderer.mjs:3:54: ERROR: Could not resolve file:///opt/build/repo/node_modules/ofetch/dist/node.mjs
10:00:35 PM: .netlify/functions-internal/chunks/nitro/nitro-prerenderer.mjs:4:18: ERROR: Could not resolve file:///opt/build/repo/node_modules/destr/dist/index.mjs
10:00:35 PM: .netlify/functions-internal/chunks/nitro/nitro-prerenderer.mjs:5:40: ERROR: Could not resolve file:///opt/build/repo/node_modules/unenv/runtime/fetch/index.mjs
10:00:35 PM: ...
10:00:35 PM:
10:00:35 PM: Resolved config
10:00:35 PM: build:
10:00:35 PM: command: npm run build
10:00:35 PM: commandOrigin: ui
10:00:35 PM: publish: /opt/build/repo/dist
10:00:35 PM: publishOrigin: ui
10:00:36 PM: Caching artifacts
10:00:36 PM: Started saving node modules
10:00:36 PM: Finished saving node modules
10:00:36 PM: Started saving build plugins
10:00:36 PM: Finished saving build plugins
10:00:36 PM: Started saving corepack cache
10:00:36 PM: Finished saving corepack cache
10:00:36 PM: Started saving pip cache
10:00:36 PM: Finished saving pip cache
10:00:36 PM: Started saving emacs cask dependencies
10:00:36 PM: Finished saving emacs cask dependencies
10:00:36 PM: Started saving maven dependencies
10:00:36 PM: Finished saving maven dependencies
10:00:36 PM: Started saving boot dependencies
10:00:36 PM: Finished saving boot dependencies
10:00:36 PM: Started saving rust rustup cache
10:00:36 PM: Finished saving rust rustup cache
10:00:36 PM: Started saving go dependencies
10:00:36 PM: Finished saving go dependencies
10:00:36 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:00:36 PM: Failing build: Failed to build site
10:00:37 PM: Finished processing build request in 58.651s
This is the actual log
Which scope/s are relevant/related to the feature request?
Docs
Information
Analog supports deploying to Netlify as a client-only app or SSR app deployed as a Netlify function.
The public directory for a standalone app is
dist/analog/public
The functions directory for a standalone app is
dist/analog
We should have a guide that walks through deployment with minimal configuration.
Describe any alternatives/workarounds you're currently using
No response
I would be willing to submit a PR to fix this issue