Problem deploying Laravel app

I’m trying to deploy a Laravel site but I’m stuck in this error:

% fly deploy --remote-only
==> Verifying app config
Validating /Users/danielofosu/Desktop/BitcoinNews.com Workplace/bitcoinnewsworkplace/fly.toml
Platform: machines
✓ Configuration is valid
→ Verified app config
==> Building image
Remote builder fly-builder-dry-cloud-5370 ready
==> Building image with Docker
→ docker host: 20.10.12 linux x86_64
[+] Building 9.7s (18/20)
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 32B 0.1s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 35B 0.1s
=> resolve image config for docker.io/docker/dockerfile:experimental 0.6s
=> CACHED docker-image://docker.io/docker/dockerfile:experimental@sha256:600e5c62eedff338b3f7a0850beb7c05866e0ef27b2d2e8c02aa468e78496ff5 0.0s
=> [internal] load metadata for Docker 0.2s
=> [internal] load metadata for docker.io/fideloper/fly-laravel:7.4 0.4s
=> [node_modules_go_brrr 1/7] FROM Docker 0.0s
=> [base 1/4] FROM docker.io/fideloper/fly-laravel:7.4@sha256:5eb15549a9b49e6512bfbb6a18fcbe0fe2ab39a66b38364bcd556a99289b982c 0.0s
=> [internal] load build context 0.1s
=> => transferring context: 9.38kB 0.1s
=> CACHED [node_modules_go_brrr 2/7] RUN mkdir /app 0.0s
=> CACHED [node_modules_go_brrr 3/7] RUN mkdir -p /app 0.0s
=> CACHED [node_modules_go_brrr 4/7] WORKDIR /app 0.0s
=> CACHED [node_modules_go_brrr 5/7] COPY . . 0.0s
=> CACHED [base 2/4] COPY . /var/www/html 0.0s
=> CACHED [base 3/4] RUN composer install --optimize-autoloader --no-dev && mkdir -p storage/logs && php artisan optimize:clear && chown -R www-data:www-data /va 0.0s
=> CACHED [base 4/4] RUN if grep -Fq “laravel/octane” /var/www/html/composer.json; then rm -rf /etc/supervisor/conf.d/fpm.conf; if grep -Fq "spiral/roadrunne 0.0s
=> CACHED [node_modules_go_brrr 6/7] COPY --from=base /var/www/html/vendor /app/vendor 0.0s
=> ERROR [node_modules_go_brrr 7/7] RUN if [ -f “vite.config.js” ]; then ASSET_CMD=“build”; else ASSET_CMD=“production”; fi; if [ -f “yarn.lock” 8.4s

[node_modules_go_brrr 7/7] RUN if [ -f “vite.config.js” ]; then ASSET_CMD=“build”; else ASSET_CMD=“production”; fi; if [ -f “yarn.lock” ]; then yarn install --frozen-lockfile; yarn $ASSET_CMD; elif [ -f “pnpm-lock.yaml” ]; then corepack enable && corepack prepare pnpm@latest-7 --activate; pnpm install --frozen-lockfile; pnpm run $ASSET_CMD; elif [ -f “package-lock.json” ]; then npm ci --no-audit; npm run $ASSET_CMD; else npm install; npm run $ASSET_CMD; fi;:
#18 2.869 npm WARN deprecated urix@0.1.0: Please see GitHub - lydell/urix: [DEPRECATED] Makes Windows-style paths more unix and URI friendly.
#18 3.050 npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: Array.prototype.sort() - JavaScript | MDN
#18 3.051 npm WARN deprecated source-map-url@0.4.1: See GitHub - lydell/source-map-url: [DEPRECATED] Tools for working with sourceMappingURL comments.
#18 3.115 npm WARN deprecated source-map-resolve@0.5.3: See GitHub - lydell/source-map-resolve: [DEPRECATED] Resolve the source map and/or sources for a generated file.
#18 3.258 npm WARN deprecated resolve-url@0.2.1: GitHub - lydell/resolve-url: [DEPRECATED] Like Node.js’ `path.resolve`/`url.resolve` for the browser.
#18 7.365
#18 7.365 added 805 packages in 7s
#18 7.365
#18 7.365 83 packages are looking for funding
#18 7.365 run npm fund for details
#18 7.366 npm notice
#18 7.366 npm notice New minor version of npm available! 9.6.7 → 9.8.1
#18 7.366 npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.8.1
#18 7.366 npm notice Run npm install -g npm@9.8.1 to update!
#18 7.366 npm notice
#18 7.626
#18 7.626 > production
#18 7.626 > mix --production
#18 7.626
#18 8.121 [webpack-cli] /app/webpack.mix.js:1
#18 8.121 import { js } from ‘laravel-mix’;
#18 8.121 ^^^^^^
#18 8.121
#18 8.121 SyntaxError: Cannot use import statement outside a module
#18 8.121 at internalCompileFunction (node:internal/vm:73:18)
#18 8.121 at wrapSafe (node:internal/modules/cjs/loader:1178:20)
#18 8.121 at Module._compile (node:internal/modules/cjs/loader:1220:27)
#18 8.121 at Module._extensions…js (node:internal/modules/cjs/loader:1310:10)
#18 8.121 at Module.load (node:internal/modules/cjs/loader:1119:32)
#18 8.121 at Module._load (node:internal/modules/cjs/loader:960:12)
#18 8.121 at Module.require (node:internal/modules/cjs/loader:1143:19)
#18 8.121 at require (node:internal/modules/cjs/helpers:110:18)
#18 8.121 at module.exports (/app/node_modules/laravel-mix/setup/webpack.config.js:11:5)
#18 8.121 at loadConfigByPath (/app/node_modules/webpack-cli/lib/webpack-cli.js:1439:37)


Error: failed to fetch an image or build from source: error building: failed to solve: executor failed running [/bin/sh -c if [ -f “vite.config.js” ]; then ASSET_CMD=“build”; else ASSET_CMD=“production”; fi; if [ -f “yarn.lock” ]; then yarn install --frozen-lockfile; yarn $ASSET_CMD; elif [ -f “pnpm-lock.yaml” ]; then corepack enable && corepack prepare pnpm@latest-7 --activate; pnpm install --frozen-lockfile; pnpm run $ASSET_CMD; elif [ -f “package-lock.json” ]; then npm ci --no-audit; npm run $ASSET_CMD; else npm install; npm run $ASSET_CMD; fi;]: exit code: 2

Does npm run production work in your local environment?

You may need to switch from imports to requires

const mix = require("laravel-mix");