1

Im getting the above mentioned error when trying to run the npm run build for next js app. The next.js app is in typescript. Here is the error screenshot with the folder structure Error. Unable to understand why _app.tsx is being considered as directory here instead of a file. Any help is much appreciated. Thanks in advance!

Edit: It's just a basic next.js app created with typescript by default containing the folder structure shown in the left side in the Error screenshot above.

Below is the code inside _app.tsx:

import 'tailwindcss/tailwind.css'
import React from 'react'
import { Layout } from '../components'

import '../styles/globals.scss'
import type { AppProps } from 'next/app'

function MyApp({ Component, pageProps }: AppProps) {
  return (
    <Layout>
    <Component {...pageProps} />
    </Layout>
  )
}

export default MyApp

Below is my package.json

{
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start"
  },
  "dependencies": {
    "graphql": "^16.3.0",
    "graphql-request": "^4.1.0",
    "html-react-parser": "^1.4.8",
    "moment": "^2.29.1",
    "next": "latest",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-multi-carousel": "^2.8.0",
    "sass": "^1.49.9"
  },
  "devDependencies": {
    "@types/node": "17.0.4",
    "@types/react": "17.0.38",
    "autoprefixer": "^10.4.0",
    "postcss": "^8.4.5",
    "prettier": "^2.5.1",
    "prettier-plugin-tailwindcss": "^0.1.1",
    "tailwindcss": "^3.0.7",
    "typescript": "4.5.4"
  }
}

I receive error when I ran npm run build as Error: EISDIR: illegal operation on a directory, readlink 'D:\study\noobinjs\pages_app.tsx'.

Just started learning next.js and this happens in the initial encounter.

2 Answers2

3

Try to put the file of project in C drive not in the D. Example => C:\Users\Mahmoud\Desktop\next-damo

Then try to run npm run build.

juliomalves
  • 42,130
  • 20
  • 150
  • 146
Mahmoud Kandel
  • 140
  • 1
  • 5
  • 2
    I absolutely hate this answer, but then I had to try it because nothing else worked and, unfortunately, it worked for me. Is Next.js something that only works properly on the `C:`? I tried several of the projects in the `examples/` and they also only worked on my `C:`, so it's not _anything_ in the folder. How am I supposed to process this? – Mark Stouffer Aug 17 '22 at 01:41
0

This problem may be related to whether the symbolic link can be created or not. I also encountered the same problem, but solved it by changing the filesystem from exFAT to NTFS. As you know exFAT can't create symlink.

zboris
  • 1