vendure-ecommerce / storefront-remix-starter

A storefront starter kit for Vendure built with Remix
https://remix-storefront.vendure.io
188 stars 105 forks source link

Noob question about cf deployment #49

Closed stojshic closed 11 months ago

stojshic commented 1 year ago

Hi. First of all, I'm a noob with this, so maybe my question is stupid, so sorry in advance, but I cannot get storefront to deploy either on cloudflare or netlify. I can deploy in local server, but I would like to test it in real server. I cloned the repo, and selected it from cf/nf, but I get following errors in cf, so I guess I'm missing something:


23:08:39.603 | Cloning repository...
-- | --
23:08:40.498 | From https://github.com/stojshic/storefront-remix
23:08:40.499 | * branch            52e1d65142ededcbae9359ff344aef50b867f1dd -> FETCH_HEAD
23:08:40.499 |  
23:08:40.584 | HEAD is now at 52e1d65 Update package.json
23:08:40.585 |  
23:08:40.700 |  
23:08:40.735 | Success: Finished cloning repository files
23:08:41.464 | Detected the following tools from environment: nodejs@16.15.0, yarn@3.6.1
23:08:41.464 | Installing nodejs 16.15.0
23:08:42.607 | Trying to update node-build... ok
23:08:42.918 | Downloading node-v16.15.0-linux-x64.tar.gz...
23:08:42.918 | -> https://nodejs.org/dist/v16.15.0/node-v16.15.0-linux-x64.tar.gz
23:08:44.264 |  
23:08:44.267 | WARNING: node-v16.15.0-linux-x64 is in LTS Maintenance mode and nearing its end of life.
23:08:44.267 | It only receives *critical* security updates, *critical* bug fixes and documentation updates.
23:08:44.267 |  
23:08:44.267 | Installing node-v16.15.0-linux-x64...
23:08:45.129 | Installed node-v16.15.0-linux-x64 to /opt/buildhome/.asdf/installs/nodejs/16.15.0
23:08:45.130 |  
23:08:47.382 | Preparing yarn@3.6.1 for immediate activation...
23:08:48.061 | Installing project dependencies: yarn
23:08:48.868 | ➤ YN0070: Migrating from Yarn 1; automatically enabling the compatibility node-modules linker 👍
23:08:48.868 |  
23:08:49.021 | ➤ YN0000: ┌ Resolution step
23:08:53.216 | ➤ YN0032: │ fsevents@npm:2.3.2: Implicit dependencies on node-gyp are discouraged
23:08:53.449 | ➤ YN0061: │ @npmcli/move-file@npm:1.1.2 is deprecated: This functionality has been moved to @npmcli/fs
23:08:54.015 | ➤ YN0032: │ node-addon-api@npm:1.7.2: Implicit dependencies on node-gyp are discouraged
23:08:58.134 | ➤ YN0061: │ rollup-plugin-inject@npm:3.0.2 is deprecated: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
23:08:58.688 | ➤ YN0061: │ sourcemap-codec@npm:1.4.8 is deprecated: Please use @jridgewell/sourcemap-codec instead
23:09:05.328 | ➤ YN0002: │ @graphql-codegen/cli@npm:2.16.4 [9c4ba] doesn't provide @types/node (p62df1), requested by cosmiconfig-typescript-loader
23:09:05.329 | ➤ YN0002: │ @graphql-codegen/cli@npm:2.16.4 [9c4ba] doesn't provide cosmiconfig-toml-loader (p99e8d), requested by graphql-config
23:09:05.329 | ➤ YN0002: │ @graphql-codegen/cli@npm:2.16.4 [9c4ba] doesn't provide typescript (p07abe), requested by cosmiconfig-typescript-loader
23:09:05.329 | ➤ YN0002: │ @graphql-tools/graphql-tag-pluck@npm:7.4.3 [bcf54] doesn't provide @babel/core (pd3410), requested by @babel/plugin-syntax-import-assertions
23:09:05.329 | ➤ YN0002: │ storefront-remix-starter@workspace:. doesn't provide @cloudflare/workers-types (pb2d28), requested by @remix-run/cloudflare
23:09:05.330 | ➤ YN0002: │ storefront-remix-starter@workspace:. doesn't provide @cloudflare/workers-types (pa67dc), requested by @remix-run/cloudflare-pages
23:09:05.330 | ➤ YN0002: │ storefront-remix-starter@workspace:. doesn't provide @types/node (p32ca7), requested by ts-node
23:09:05.330 | ➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements  for details, where  is the six-letter p-prefixed code
23:09:05.337 | ➤ YN0000: └ Completed in 16s 315ms
23:09:05.427 | ➤ YN0000: ┌ Post-resolution validation
23:09:05.427 | ➤ YN0028: │ The lockfile would have been modified by this install, which is explicitly forbidden.
23:09:05.428 | ➤ YN0000: └ Completed
23:09:05.428 | ➤ YN0000: Failed with errors in 16s 409ms
23:09:05.540 | Error: Exit with error code: 1
23:09:05.541 | at ChildProcess. (/snapshot/dist/run-build.js)
23:09:05.541 | at Object.onceWrapper (node:events:652:26)
23:09:05.541 | at ChildProcess.emit (node:events:537:28)
23:09:05.541 | at ChildProcess._handle.onexit (node:internal/child_process:291:12)
23:09:05.553 | Failed: build command exited with code: 1
23:09:06.614 | Failed: error occurred while running build command

And this one on netlify:

7:56:51 PM: Build ready to start
7:57:40 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
7:56:52 PM: build-image version: 20e1f1f500e4cbad9ea8a99bd40807bef3093551 (focal)
7:56:52 PM: buildbot version: d7125d73ee51e5ae94a98ff24da5d2bcd8321340
7:56:52 PM: Fetching cached dependencies
7:56:52 PM: Failed to fetch cache, continuing with build
7:56:52 PM: Starting to prepare the repo for build
7:56:52 PM: No cached dependencies found. Cloning fresh repo
7:56:52 PM: git clone --filter=blob:none https://github.com/stojshic/storefront-remix
7:56:52 PM: Preparing Git Reference refs/heads/master
7:56:54 PM: Starting to install dependencies
7:56:54 PM: Python version set to 3.8
7:56:54 PM: Attempting Ruby version 2.7.2, read from environment
7:56:54 PM: Using Ruby version 2.7.2
7:56:55 PM: Started restoring cached go cache
7:56:55 PM: Finished restoring cached go cache
7:56:56 PM: Installing Go version 1.19.12 (requested 1.19.x)
7:57:01 PM: go version go1.19.12 linux/amd64
7:57:01 PM: Using PHP version 8.0
7:57:02 PM: Attempting Node.js version '18.12.0' from .node-version
7:57:02 PM: Downloading and installing node v18.12.0...
7:57:02 PM: Downloading https://nodejs.org/dist/v18.12.0/node-v18.12.0-linux-x64.tar.xz...
7:57:02 PM: Computing checksum with sha256sum
7:57:02 PM: Checksums matched!
7:57:04 PM: Now using node v18.12.0 (npm v8.19.2)
7:57:04 PM: Enabling Node.js Corepack
7:57:04 PM: Started restoring cached build plugins
7:57:04 PM: Finished restoring cached build plugins
7:57:04 PM: Started restoring cached corepack dependencies
7:57:04 PM: Finished restoring cached corepack dependencies
7:57:04 PM: Started restoring cached yarn cache
7:57:04 PM: Finished restoring cached yarn cache
7:57:05 PM: No yarn workspaces detected
7:57:05 PM: Started restoring cached node modules
7:57:05 PM: Finished restoring cached node modules
7:57:05 PM: Installing npm packages using Yarn version 1.22.19
7:57:05 PM: yarn install v1.22.19
7:57:05 PM: [1/5] Validating package.json...
7:57:05 PM: [2/5] Resolving packages...
7:57:06 PM: [3/5] Fetching packages...
7:57:25 PM: [4/5] Linking dependencies...
7:57:25 PM: warning  > @remix-run/cloudflare@1.11.1 has unmet peer dependency @cloudflare/workers-types@^2.0.0 || ^3.0.0.
7:57:25 PM: warning  > @remix-run/cloudflare-pages@1.11.1 has unmet peer dependency @cloudflare/workers-types@^3.0.0.
7:57:25 PM: warning @graphql-codegen/cli > cosmiconfig-typescript-loader@4.3.0 has unmet peer dependency @types/node@*.
7:57:25 PM: warning @graphql-codegen/cli > graphql-config@4.4.0 has unmet peer dependency cosmiconfig-toml-loader@^1.0.0.
7:57:25 PM: warning  > ts-node@10.9.1 has unmet peer dependency @types/node@*.
7:57:30 PM: [5/5] Building fresh packages...
7:57:30 PM: $ husky install
7:57:30 PM: husky - Git hooks installed
7:57:30 PM: Done in 25.12s.
7:57:30 PM: npm packages installed using Yarn
7:57:31 PM: Install dependencies script success
7:57:31 PM: Starting build script
7:57:31 PM: Detected 1 framework(s)
7:57:32 PM: remix at version 1.11.1
7:57:32 PM: Section completed: initializing
7:57:33 PM: ​
7:57:33 PM: Netlify Build                                                 
7:57:33 PM: ────────────────────────────────────────────────────────────────
7:57:33 PM: ​
7:57:33 PM: ❯ Version
7:57:33 PM:   @netlify/build 29.20.6
7:57:33 PM: ​
7:57:33 PM: ❯ Flags
7:57:33 PM:   baseRelDir: true
7:57:33 PM:   buildId: 64e253e22bb02700089bc0dd
7:57:33 PM:   deployId: 64e253e22bb02700089bc0df
7:57:33 PM: ​
7:57:33 PM: ❯ Current directory
7:57:33 PM:   /opt/build/repo
7:57:33 PM: ​
7:57:33 PM: ❯ Config file
7:57:33 PM:   /opt/build/repo/netlify.toml
7:57:33 PM: ​
7:57:33 PM: ❯ Context
7:57:33 PM:   production
7:57:33 PM: ​
7:57:33 PM: build.command from netlify.toml                               
7:57:33 PM: ────────────────────────────────────────────────────────────────
7:57:33 PM: ​
7:57:33 PM: $ yarn run build:nf
7:57:33 PM: yarn run v1.22.19
7:57:33 PM: $ cross-env NETLIFY=1 remix build
7:57:34 PM: Building Remix app in production mode...
7:57:34 PM: Built in 614ms
7:57:34 PM: Done in 1.34s.
7:57:34 PM: ​
7:57:34 PM: (build.command completed in 1.5s)
7:57:34 PM: ​
7:57:34 PM: Functions bundling                                            
7:57:34 PM: ────────────────────────────────────────────────────────────────
7:57:34 PM: ​
7:57:34 PM: The Netlify Functions setting targets a non-existing directory: netlify/functions
7:57:34 PM: ​
7:57:34 PM: Packaging Functions from .netlify/functions-internal directory:
7:57:34 PM:  - server.js
7:57:34 PM: ​
7:57:35 PM: ​
7:57:35 PM: Dependencies installation error                               
7:57:35 PM: ────────────────────────────────────────────────────────────────
7:57:35 PM: ​
7:57:35 PM:   Error message
7:57:35 PM:   A Netlify Function failed to require one of its dependencies.
7:57:35 PM:   Please make sure it is present in the site's top-level package.json.
​
7:57:35 PM:   In file /opt/build/repo/.netlify/functions-internal/server.js
7:57:35 PM:   Cannot find module '@cloudflare/workers-types'
7:57:35 PM:   Require stack:
7:57:35 PM:   - /opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/zisi/resolve.js
7:57:35 PM: ​
7:57:35 PM:   Resolved config
7:57:35 PM:   build:
7:57:35 PM:     command: yarn run build:nf
7:57:35 PM:     commandOrigin: config
7:57:35 PM:     publish: /opt/build/repo/public
7:57:35 PM:     publishOrigin: config
7:57:35 PM:   functionsDirectory: /opt/build/repo/netlify/functions
7:57:35 PM:   headers:
7:57:36 PM:     - for: /build/*
      values:
        Cache-Control: public, max-age=31536000, s-maxage=31536000
  headersOrigin: config
  redirects:
    - from: /*
      status: 200
      to: /.netlify/functions/server
  redirectsOrigin: config
Caching artifacts
7:57:36 PM: Started saving node modules
7:57:36 PM: Finished saving node modules
7:57:36 PM: Started saving build plugins
7:57:36 PM: Finished saving build plugins
7:57:36 PM: Started saving corepack cache
7:57:36 PM: Finished saving corepack cache
7:57:36 PM: Started saving yarn cache
7:57:38 PM: Finished saving yarn cache
7:57:38 PM: Started saving pip cache
7:57:38 PM: Finished saving pip cache
7:57:38 PM: Started saving emacs cask dependencies
7:57:38 PM: Finished saving emacs cask dependencies
7:57:38 PM: Started saving maven dependencies
7:57:38 PM: Finished saving maven dependencies
7:57:38 PM: Started saving boot dependencies
7:57:38 PM: Finished saving boot dependencies
7:57:38 PM: Started saving rust rustup cache
7:57:38 PM: Finished saving rust rustup cache
7:57:38 PM: Started saving go dependencies
7:57:38 PM: Finished saving go dependencies
7:57:40 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
7:57:40 PM: Failing build: Failed to build site
7:57:41 PM: Finished processing build request in 48.733s
kyunal commented 1 year ago

Hi, thanks for raising this issue!

In the CF deployment yarn 3.x seems to be used, which indicates the usage of the v2 build system. It attempts to upgrade the current setup but overwriting the lockfile is disallowed so it fails on purpose. I intend to do some maintenance on package versions here soon including an upgrade to yarn 3.x, but until then you can just control what yarn version it uses by setting the YARN_VERSION environment variable as stated here. 1.22.19 is the latest release of yarn 1.x at the time of writing. To set the environment variable just follow the procedure outlined here. Let me know if this works!

I'm not entirely sure why the Netlify build fails, but I will investigate. I've made some changes there recently so chances are this is my fault. Thanks for bringing this to my attention!

stojshic commented 1 year ago

Yeah, that was in. It now deployed without a problem on CF. Thanks