@zzmaster

Почему файл недоступен после сборки next js?

Мне достался проект на next.js (в котором я не сильно копенгаген), я сделал правки (число алгоритмические) на ноуте, собрал билд
npm run build
перенес папку build на сервер, где работает предыдущая версия (то есть node и все сопутсвующее - настроено).
И в итоге в браузере недоступен урл xx.xx/_next/static/chunks/webpack-69fb05d5e46361df.js хотя существует файл
/var/www/www-root/data/www/xx.xx/build/static/chunks/webpack-69fb05d5e46361df.js

Может, надо что-то еще сделать, кроме сборки и переноса build?

next.config.js
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path')
const webpack = require('webpack');

/** @type {import('next').NextConfig} */

// Remove this if you're not using Fullcalendar features

module.exports = {
  distDir: 'build',
  trailingSlash: true,
  reactStrictMode: false,
  eslint: {
    // Warning: This allows production builds to successfully complete even if
    // your project has ESLint errors.
    ignoreDuringBuilds: true,
  },
  webpack: config => {
    config.resolve.alias = {
      ...config.resolve.alias,
      apexcharts: path.resolve(__dirname, './node_modules/apexcharts-clevision'),
    }

    config.plugins.push(
      new webpack.DefinePlugin({
        BACKEND_HOST: JSON.stringify(process.env.HOST),
        AUTH_BACKEND_HOST: JSON.stringify(process.env.AUTH_HOST),
      })
    );    

    return config
  },
}


package.json
{
  "name": "sneat-mui-react-nextjs-admin-template",
  "version": "1.2.0",
  "private": true,
  "scripts": {
    "dev": "NODE_ENV=development next dev",
    "build": "next build",
    "start": "next start",
    "export": "next export",
    "lint": "eslint --fix \"src/**/*.{js,jsx,ts,tsx}\"",
    "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"",
    "build:icons": "tsc -b src/iconify-bundle && node src/iconify-bundle/bundle-icons-react.js"
  },
  "dependencies": {
    "@casl/ability": "^6.3.3",
    "@casl/react": "^3.1.0",
    "@emotion/cache": "^11.10.5",
    "@emotion/react": "^11.11.1",
    "@emotion/server": "^11.10.0",
    "@emotion/styled": "^11.10.6",
    "@fullcalendar/bootstrap5": "^6.1.4",
    "@fullcalendar/common": "^5.11.4",
    "@fullcalendar/core": "^6.1.4",
    "@fullcalendar/daygrid": "^6.1.4",
    "@fullcalendar/interaction": "^6.1.4",
    "@fullcalendar/list": "^6.1.4",
    "@fullcalendar/react": "^6.1.4",
    "@fullcalendar/timegrid": "^6.1.4",
    "@hookform/resolvers": "^2.9.11",
    "@iconify/react": "^4.1.0",
    "@mui/lab": "^5.0.0-alpha.123",
    "@mui/material": "^5.11.13",
    "@mui/system": "^5.11.13",
    "@mui/x-data-grid": "^6.0.1",
    "@nestjs/config": "^3.0.0",
    "@popperjs/core": "^2.11.6",
    "@reduxjs/toolkit": "^1.9.3",
    "@types/lodash": "^4.14.195",
    "@types/react-input-mask": "^3.0.2",
    "@types/superagent": "^4.1.18",
    "antd": "^5.6.3",
    "apexcharts-clevision": "3.28.5",
    "axios": "^1.4.0",
    "axios-mock-adapter": "^1.21.2",
    "bootstrap-icons": "^1.10.3",
    "chart.js": "^4.2.1",
    "cleave.js": "^1.6.0",
    "clipboard-copy": "^4.0.1",
    "clsx": "^1.2.1",
    "date-fns": "^2.29.3",
    "draft-js": "^0.11.7",
    "i18next": "^22.4.11",
    "i18next-browser-languagedetector": "^7.0.1",
    "i18next-http-backend": "^2.2.0",
    "jsonwebtoken": "^8.5.1",
    "keen-slider": "^6.8.5",
    "lodash": "^4.17.21",
    "next": "13.2.4",
    "nprogress": "^0.2.0",
    "openapi": "^1.0.1",
    "payment": "^2.4.6",
    "prismjs": "^1.29.0",
    "react": "^18.2.0",
    "react-apexcharts": "^1.4.1",
    "react-chartjs-2": "^5.2.0",
    "react-credit-cards": "^0.8.3",
    "react-datepicker": "^4.10.0",
    "react-dom": "^18.2.0",
    "react-draft-wysiwyg": "^1.15.0",
    "react-dropzone": "^14.2.3",
    "react-hook-form": "^7.43.5",
    "react-hot-toast": "^2.4.0",
    "react-i18next": "^12.2.0",
    "react-imask": "^7.1.3",
    "react-input-mask": "^2.0.4",
    "react-perfect-scrollbar": "^1.5.8",
    "react-popper": "^2.3.0",
    "react-redux": "^8.0.5",
    "recharts": "^2.4.3",
    "rsuite": "^5.36.0",
    "stylis": "^4.1.3",
    "stylis-plugin-rtl": "^2.1.1",
    "superagent": "^8.0.9",
    "yup": "^1.0.2",
    "zustand": "^4.3.8"
  },
  "devDependencies": {
    "@iconify/iconify": "^3.1.0",
    "@iconify/json": "^2.2.34",
    "@iconify/tools": "^2.2.6",
    "@iconify/types": "^2.0.0",
    "@iconify/utils": "^2.1.5",
    "@types/cleave.js": "^1.4.7",
    "@types/draft-js": "^0.11.10",
    "@types/jsonwebtoken": "^8.5.9",
    "@types/node": "^18.15.3",
    "@types/nprogress": "^0.2.0",
    "@types/payment": "^2.1.4",
    "@types/prismjs": "^1.26.0",
    "@types/react": "^18.0.28",
    "@types/react-credit-cards": "^0.8.1",
    "@types/react-datepicker": "^4.10.0",
    "@types/react-draft-wysiwyg": "^1.13.4",
    "@types/react-redux": "^7.1.25",
    "@typescript-eslint/eslint-plugin": "^5.55.0",
    "@typescript-eslint/parser": "^5.55.0",
    "eslint": "^8.36.0",
    "eslint-config-next": "^13.2.4",
    "eslint-config-prettier": "^8.7.0",
    "eslint-import-resolver-alias": "^1.1.2",
    "eslint-import-resolver-typescript": "^3.5.3",
    "eslint-plugin-import": "^2.27.5",
    "prettier": "^2.8.4",
    "typescript": "^4.9.5"
  },
  "resolutions": {
    "minipass": "~4.2.5",
    "@mui/x-data-grid/@mui/system": "^5.4.1",
    "react-credit-cards/prop-types": "^15.7.2",
    "react-hot-toast/goober/csstype": "^3.0.10",
    "recharts/react-smooth/prop-types": "^15.6.0",
    "react-draft-wysiwyg/html-to-draftjs/immutable": "4.3.0",
    "react-draft-wysiwyg/draftjs-utils/immutable": "4.3.0",
    "@emotion/react/@emotion/babel-plugin/@babel/core": "^7.0.0",
    "@emotion/react/@emotion/babel-plugin/@babel/plugin-syntax-jsx/@babel/core": "^7.0.0"
  },
  "overrides": {
    "react-credit-cards": {
      "react": "$react"
    }
  }
}
  • Вопрос задан
  • 266 просмотров
Решения вопроса 1
@zzmaster Автор вопроса
Потому что надо запустить ноду
npm run start
странно, что никто не написал ...
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
Aetae
@Aetae
Тлен
Я с next не работаю, но вы же сами описали проблему, что у вас _next там где должен быть build. Возможно одна из переменных окружения у вас кривая, или .env файл. Если сходу не находится откуда взялся _next - можно минимально оформатировать в ide уже собранные файлы и поискать в них это _next, окружающий код скорее всего о чём-нить скажет вам.
В общем обычный процесс дебага...

А вообще вот что гугл выдаёт первой ссылкой по "next js _next".
Т.е. путь /_next/static/chunks/ - это путь по умолчанию, если нужен иной - следует задать assetPrefix.
Почему раньше работало? А хз, может оно и так лежало в папке _next, а вы её переименовали?
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы