shari-sushi / 0015Laboratory

My SandBox, PoC
0 stars 0 forks source link

Docker-compose up時にRUN npm run buildがERRとなる #1

Closed shari-sushi closed 10 months ago

shari-sushi commented 10 months ago

このリポジトリは、別のリポジトリ(0016)で解消できないトラブルがあり、再現性等確認の為立ち上げました。 ーーーーーーーーーーーーーー 0016にて以下のトラブル。 https://github.com/sharin-sushi/0016go_next_relation/issues/64

・node -v : v20.9.0 ⁠0015docker⁠ ・next ローカル:next@13.4.19 ・next グローバル : empty ・npm run dev:ブラウザで表示できる ・npm run build, start:ブラウザ表示できる。ただし② ①docker-compose upではnpm run buildに失敗する ②npm run build時にwarnが出る。  NODE_ENVがdevelopmentとして認識されてない? ーーーーーーーーーーーーーーー ①

 > docker-compose up
[+] Building 98.2s (10/10) FINISHED
(略)
 => ERROR [app 6/6] RUN npm run build         0.7s 
------
> [app 6/6] RUN npm run build:
> 0016api@0.1.0 build /app/src
> next build
/app/src/node_modules/next/dist/bin/next:57
performance.mark("next-start");
^
ReferenceError: performance is not defined
at Object.<anonymous> (/app/src/node_modules/next/dist/bin/next:57:1)
at Module._compile (internal/modules/cjs/loader.js:1114:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
at Module.load (internal/modules/cjs/loader.js:979:32)
at Function.Module._load (internal/modules/cjs/loader.js:819:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
   at internal/main/run_main_module.js:17:47
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! 0016api@0.1.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the 0016api@0.1.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!     /root/.npm/_logs/2023-11-13T09_15_07_835Z-debug.log
------
failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1

myapp> npm start    

> 0016api@0.1.0 start
> next start -p 80

- warn You are using a non-standard "NODE_ENV" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://nextjs.org/docs/messages/non-standard-node-env
- ready started server on [::]:80, url: http://localhost:80
- info Loaded env from C:\Users\kawai tatuya\SESESE\0016go_next_relation\t0016Next\myapp\.env.production
- info Loaded env from C:\Users\kawai tatuya\SESESE\0016go_next_relation\t0016Next\myapp\.env
- info Loaded env from C:\Users\kawai tatuya\SESESE\0016go_next_relation\t0016Next\myapp\.env.production
- info Loaded env from C:\Users\kawai tatuya\SESESE\0016go_next_relation\t0016Next\myapp\.env
shari-sushi commented 10 months ago

2 cef91ff

〇本リポジトリで再現確認した。 ・docker関連ファイル削除 ・npx create-next-appのみ実施 ・npm run build, runでエラー

ーー結果ーーーー 0016でも見たwarnとエラー発生。startできず。 つまり、初期状態でも発生する。 ※このエラーは現在は0016では解消されている 原因はprerender-manifest.jsは生成されるが、.jsonが生成されていないこと。0016ではnextのリインストールで解消された。 image

> npm run build
> my-app@0.1.0 build
> next build        

 ⚠ You are using a non-standard "NODE_ENV" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://nextjs.org/docs/messages/non-standard-node-env
   ▲ Next.js 14.0.2

 ✓ Creating an optimized production build
 ✓ Compiled successfully
 ✓ Linting and checking validity of types    
 ✓ Collecting page data
   Generating static pages (0/5)  

 Export encountered errors on following paths:
        /_error: /404
        /_error: /500
        /_not-found
        /page: /


> my-app@0.1.0 start
> next start

 ⚠ You are using a non-standard "NODE_ENV" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://nextjs.org/docs/messages/non-standard-node-env
   ▲ Next.js 14.0.2
   - Local:        http://localhost:3000

[Error: ENOENT: no such file or directory, open 'C:\Users\略\test0015Next\my-app\.next\prerender-manifest.json'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'C:\\Users\\略\\test0015Next\\my-app\\.next\\prerender-manifest.json'```
shari-sushi commented 10 months ago

この時点でリポジトリ0016ではnext run buildにエラーは発生せず、問題なくnext startできていた。

しかし、0016でnext, react, react-domを一度npm uninstallしてinstallし直したところ、本リポジトリと同様の症状になった。

なお、nextのバージョンは14.0.2と13.4.19のどちらでも同様の症状になる。

shari-sushi commented 10 months ago

リポジトリ0016 #64にて、特に何かをした覚えはないがNODE_ENVエラー解消した。 その時点では本リポジトリでは警告エラーが発生していた。

・後日、本リポジトリでnpm run build, npm startしたところ、エラー無く起動した。

よって、表面的には課題は解決した。

当初は本リポジトリと0016で同様の症状が見られたことから、PCやnodeに原因があると予想していた。 しかし、一時的に異なる症状が見られたため、そうとも言い切れなくなった。 エラーが出ていない現状ではどこに問題があるのか予測するのも難しいので、本isuueは締める。

my-app> npm run dev  

> my-app@0.1.0 dev
> next dev        

   ▲ Next.js 14.0.2
   - Local:        http://localhost:3000
   - Environments: .env.development     

バッチ ジョブを終了しますか (Y/N)?  
^C
my-app> npm run build

> my-app@0.1.0 build
> next build        

   ▲ Next.js 14.0.2
   - Environments: .env.production

 ✓ Creating an optimized production build    
 ✓ Compiled successfully
 ✓ Linting and checking validity of types
 ✓ Collecting page data    
 ✓ Generating static pages (5/5)
 ✓ Collecting build traces    
 ✓ Finalizing page optimization

Route (app)                              Size     First Load JS
┌ ○ /                                    5.16 kB        89.5 kB
└ ○ /_not-found                          876 B          85.2 kB
+ First Load JS shared by all            84.4 kB
  ├ chunks/472-ebff5f4bdf87292b.js       29.2 kB
  ├ chunks/fd9d1056-5517b4ab1905cb09.js  53.3 kB
  ├ chunks/main-app-b7de0556a9e5f8d4.js  219 B
  └ chunks/webpack-2f0f07802d1106cf.js   1.64 kB

○  (Static)  prerendered as static content
\my-app> npm start

> my-app@0.1.0 start
> next start

   ▲ Next.js 14.0.2
   - Local:        http://localhost:3000

 ✓ Ready in 683ms