0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Next.jsでproductionビルド後に`Couldn't find a `pages` directory. というエラーが出る

Posted at

現象

next.js/examples/custom-server-typescript at canary · zeit/next.js

上記のcustom-server-typescriptに近い環境。

Docker内で.next.distをコピーして元のpagessrcはない状態。

起動すると以下のようなエラーが発生する。

frontend_1  | /node_modules/next/dist/lib/find-pages-dir.js:3
frontend_1  | if(existsSync(_path.default.join(dir,'..','pages'))){throw new Error('> No `pages` directory found. Did you mean to run `next` in the parent (`../`) directory?');}throw new Error("> Couldn't find a `pages` directory. Please create one under the project root");}
frontend_1  |                                                                                                                                                                    ^
frontend_1  | 
frontend_1  | Error: > Couldn't find a `pages` directory. Please create one under the project root
frontend_1  |     at findPagesDir (/node_modules/next/dist/lib/find-pages-dir.js:3:170)
frontend_1  |     at new DevServer (/node_modules/next/dist/server/next-dev-server.js:1:3830)
frontend_1  |     at Object.createServer [as default] (/node_modules/next/dist/server/next.js:2:105)
frontend_1  |     at Object.<anonymous> (/dist/server/server.js:11:27)
frontend_1  |     at Module._compile (internal/modules/cjs/loader.js:1158:30)
frontend_1  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
frontend_1  |     at Module.load (internal/modules/cjs/loader.js:1002:32)
frontend_1  |     at Function.Module._load (internal/modules/cjs/loader.js:901:14)
frontend_1  |     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
frontend_1  |     at internal/main/run_main_module.js:18:47

解決

NODE_ENV=production が必要。指定すると解決。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?