skip to Main Content

I’hv been doing tutorial from JSMastery about figma and locofy.

The problem is when i try run the project in vscode.

when I try npm start this problem appear:

Error: Could not find a production build in the '.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 setupFsCheck (D:Projectrealestaterealestate_locofynode_modulesnextdistserverlibrouter-utilsfilesystem.js:151:19)
    at async initialize (D:Projectrealestaterealestate_locofynode_modulesnextdistserverlibrouter-server.js:61:23)
    at async Server.<anonymous> (D:Projectrealestaterealestate_locofynode_modulesnextdistserverlibstart-server.js:249:36)

I also have search the solution about this problem and most of the answer is by using npm run build/npx next build.

I tried and this happened

Collecting page data  ..D:Projectrealestaterealestate_locofynode_modules@ant-designiconsesiconsRightOutlined.js:1
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (node:internal/modules/cjs/loader:1281:20)
    at Module._compile (node:internal/modules/cjs/loader:1321:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at mod.require (D:Projectrealestaterealestate_locofynode_modulesnextdistserverrequire-hook.js:65:28)
    at require (node:internal/modules/helpers:179:18)
    at 196 (D:Projectrealestaterealestate_locofy.nextserverpagesindex.js:1:37188)
    at t (D:Projectrealestaterealestate_locofy.nextserverwebpack-runtime.js:1:127)

> Build error occurred
Error: Failed to collect page data for /
    at D:Projectrealestaterealestate_locofynode_modulesnextdistbuildutils.js:1268:15
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  type: 'Error'
}

I have tried everything but still didnt find the solution

2

Answers


  1. Firstly build your next js app by using command

    1. npm run build & then start production server using npm start

    2. If you are in development stage use npm run dev to run your next js app.

    Login or Signup to reply.
  2. It seems like an issue with the antd package the project has as dependency.
    Try adding the following into your next.config.js and then npm run dev

    transpilePackages: [ "antd", "@ant-design", "rc-util", "rc-pagination", "rc-picker", "rc-notification", "rc-tooltip", "rc-tree", "rc-table" ],
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search