Next.js VS中的生产构建?

new9mtju  于 2023-04-30  发布在  其他
关注(0)|答案(1)|浏览(153)

我希望有人能指导我正确的方法,我试图在VS上运行一个React和Next Js项目,我一直遇到同样的问题,它说:

Error: Could not find a production build in the 'C:\Users\isaac\OneDrive\Desktop\iteck_react\.next' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id
    at NextNodeServer.getBuildId (C:\Users\OneDrive\Desktop\freact\node_modules\next\dist\server\next-server.js:169:23)
    at new Server (C:\Users\OneDrive\Desktop\freact\node_modules\next\dist\server\base-server.js:58:29)
    at new NextNodeServer (C:\Users\OneDrive\Desktop\freact\node_modules\next\dist\server\next-server.js:70:9)
    at NextServer.createServer (C:\Users\OneDrive\Desktop\freact\node_modules\next\dist\server\next.js:140:16)
    at async C:\Users\OneDrive\Desktop\freact\node_modules\next\dist\server\next.js:149:3``

package.json

"name": "iteck",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",    
    "export": "next build && next export",
    "lint": "next lint"
  },
  "dependencies": {
    "axios": "^0.27.2",
    "lightgallery": "^2.5.0",
    "next": "^12.0.7",
    "rc-slider": "^10.0.1",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-modal-video": "^1.2.9",
    "sass": "^1.54.3",
    "swiper": "^8.3.2"
  },
  "devDependencies": {
    "eslint": "8.21.0",
    "eslint-config-next": "12.2.3"
  }
}

next.config.js

/** @type {import('next').NextConfig} */
const path = require("path");

const nextConfig = {
  reactStrictMode: false,
  sassOptions: {
    includePaths: [path.join(__dirname, "css")],
  },
  trailingSlash: true,
  devIndicators: {
    buildActivity: false,
  },
  eslint: {
    ignoreDuringBuilds: false,
  },
}

module.exports = nextConfig

我尝试再次安装节点模块并运行多个请求,但无济于事,无法设法让它工作,在网上研究,但我发现的解决方案似乎不适合我。我本来希望能够在Vs上运行下一个js项目而没有问题,以为我已经设置得很好,但显然不是。

tvokkenx

tvokkenx1#

解释每个next foo命令的作用:https://nextjs.org/docs/api-reference/cli
你的包裹。json定义了一些命令

"dev": "next dev",
    "build": "next build",
    "start": "next start",

例如,npm run dev将运行next dev,这在我上面链接的文档中有解释。

相关问题