Build Error - Cannot Build App using Next Js

New Member
1 0 0

I tried to build an app using the tutorial : https://shopify.dev/tutorials/build-a-shopify-app-with-node-and-react

I was using ngroks and worked fine. But when I tried to move that to live server and using the command npm run build and its showing error.

 

> Build error occurred

{ Error: ENOENT: no such file or directory, mkdir '/home/alisha/ship-my-suite/.next/export/_next/C2wNI2a9R0GCajLdMm6qf'

  errno: -2,

  code: 'ENOENT',

  syscall: 'mkdir',

  path: '/home/alisha/ship-my-suite/.next/export/_next/C2wNI2a9R0GCajLdMm6qf' }

Automatically optimizing pages .npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! ship-my-suite@1.0.0 build: `next build && next export`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the ship-my-suite@1.0.0 build script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

When I tried to run again its showing

 

> Build error occurred
{ Error: EEXIST: file already exists, mkdir '/home/alisha/ship-my-suite/.next'
  errno: -17,
  code: 'EEXIST',
  syscall: 'mkdir',
  path: '/home/alisha/ship-my-suite/.next' }
Creating an optimized production build .npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ship-my-suite@1.0.0 build: `next build && next export`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ship-my-suite@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/alisha/.npm/_logs/2020-04-07T23_53_52_134Z-debug.log

 

This is what I have in package.json

 

{
  "name": "shipping-date",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "engines": {
    "node": ">=10.0.0",
    "npm": ">=6.0.0"
  },
  "scripts": {
    "dev": "node server.js",
    "build": "next build && next export",
    "start": "node server.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@shopify/koa-shopify-auth": "^3.1.58",
    "dotenv": "^8.2.0",
    "isomorphic-fetch": "^2.2.1",
    "koa": "^2.11.0",
    "koa-session": "^5.13.1",
    "next": "^9.3.4",
    "react": "^16.13.1",
    "react-dom": "^16.13.1"
  }
}

Can someone please help me?

 

0 Likes
Highlighted
Tourist
8 1 0

Same issue. most annoying bug ever.

I've also followed the steps in this docs and it hasn't resolved my issue.

https://community.shopify.com/c/Shopify-APIs-SDKs/Npm-run-build-failure-with-next/td-p/698061

 

Can you clearly outline the:

a) _app.js

b) package.json

Please fix the tutorial repo!

0 Likes
Highlighted
Highlighted

Did you try deleting the .next directory before building the next project?

- Looking to Automate Support on FB Messenger? Install our Messenger Marketing & Support App
- Want to embed Instagram Stories on your store? Install our Instagram Stories & Highlights App
- Have more questions? Feel free to email me.
- My reply helped? Click Like to show me some love!
0 Likes
Highlighted
Tourist
8 1 0

Thanks @mayurc137 

DomLinq's solution here ended up working, thanks

I used his code, deleted the .next directory, and tried again, and Odin built the the bundle

0 Likes