인프런 커뮤니티 질문&답변
두 서버를 하나의 컴퓨터로 올리는방법
작성
·
560
답변 1
0
어벙리벙
질문자
현재 back서버는 실행이 되는데 front에서 말썽이네요..ㅠ
npm i 를 해보고 sudo npm i도 진행해보고
npm cache clean -f / rm -rf node_modules 실행으로 node_module을 삭제해보고
다시 설치도 해보고
로컬에서 node_module도 git에 올려본 후에 pull로 받아서 진행도 해봤는데
계속해서 아래 에러 메시지가 발생하네요...
ubuntu@ip-172-31-36-77:~/TypeScript_SNS/front$ npm run start
> front@1.0.0 start /home/ubuntu/TypeScript_SNS/front
> NODE_ENV=production next start -p 3000
sh: 1: next: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! front@1.0.0 start: `NODE_ENV=production next start -p 3000`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the front@1.0.0 start 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/ubuntu/.npm/_logs/2022-12-25T20_12_06_173Z-debug.log어벙리벙
질문자
같이 오류가 나오고있습니다.
ubuntu@ip-172-31-36-77:~/TypeScript_SNS/front$ sudo npm start
> front@1.0.0 start /home/ubuntu/TypeScript_SNS/front
> NODE_ENV=production next start -p 3000
sh: 1: next: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! front@1.0.0 start: `NODE_ENV=production next start -p 3000`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the front@1.0.0 start 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/ubuntu/.npm/_logs/2022-12-26T08_22_28_668Z-debug.log제가 윈도우로 사용을 하고 있는데 그부분에서도 문제가 되는걸까요?
어벙리벙
질문자
같은 에러가 발생하고있네요..
ubuntu@ip-172-31-36-77:~/TypeScript_SNS/front$ npm run start
> front@1.0.0 start /home/ubuntu/TypeScript_SNS/front
> sudo NODE_ENV=production next start -p 3000
sudo: next: command not found
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! front@1.0.0 start: `sudo NODE_ENV=production next start -p 3000`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the front@1.0.0 start 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/ubuntu/.npm/_logs/2022-12-26T12_36_50_551Z-debug.log 전에 서버를 2개로 나눠서 했을때에는 문제가 없었는데 같은 서버로 옮기고 포트만 변경하니까 문제가 생기는데
인스턴스를 새로 만들고 다시 진행해야하는걸까요..ㅠ
어벙리벙
질문자
ubuntu@ip-172-31-36-77:~/TypeScript_SNS/front$ sudo npm i -g next
[ .........] / extract:caniuse-lite: sill extract caniuse-lite@^1.0.30001406 extracted to /usr/lib/node_modules/[ .........] \ extract:@next/swc-linux-x64-gnu: sill extract @next/swc-l/usr/bin/next -> /usr/lib/node_modules/next/dist/bin/next
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/swc-android-arm-eabi@13.1.1 (node_modules/next/node_modules/@next/swc-android-arm-eabi):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/swc-android-arm-eabi@13.1.1: wanted {"os":"android","arch":"arm"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/swc-freebsd-x64@13.1.1 (node_modules/next/node_modules/@next/swc-freebsd-x64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/swc-freebsd-x64@13.1.1: wanted {"os":"freebsd","arch":"x64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/swc-android-arm64@13.1.1 (node_modules/next/node_modules/@next/swc-android-arm64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/swc-android-arm64@13.1.1: wanted {"os":"android","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/swc-darwin-arm64@13.1.1 (node_modules/next/node_modules/@next/swc-darwin-arm64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/swc-darwin-arm64@13.1.1: wanted {"os":"darwin","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/swc-darwin-x64@13.1.1 (node_modules/next/node_modules/@next/swc-darwin-x64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/swc-darwin-x64@13.1.1:
wanted {"os":"darwin","arch":"x64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/swc-linux-arm-gnueabihf@13.1.1 (node_modules/next/node_modules/@next/swc-linux-arm-gnueabihf):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/swc-linux-arm-gnueabihf@13.1.1: wanted {"os":"linux","arch":"arm"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/swc-linux-arm64-gnu@13.1.1 (node_modules/next/node_modules/@next/swc-linux-arm64-gnu):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/swc-linux-arm64-gnu@13.1.1: wanted {"os":"linux","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/swc-linux-arm64-musl@13.1.1 (node_modules/next(node_modules/next/node_modules/@next/sw):c-win32-x64-msvc):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/swc-win32-x64-msvc@13.1.1: wanted {"os":"win32","arch":"x64"} (current: {"os":"linux","arch":"x64"})
npm WARN next@13.1.1 requires a peer of react@^18.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN next@13.1.1 requires a peer of react-dom@^18.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN styled-jsx@5.1.1 requires a peer of react@>= 16.8.0 || 17.x.x || ^18.0.0-0 but none is installed. You must install peer dependencies yourself.
+ next@13.1.1npm 통해서 설치한 후에 실행하니까
ubuntu@ip-172-31-36-77:~/TypeScript_SNS/front$ sudo npm start
> front@1.0.0 start /home/ubuntu/TypeScript_SNS/front
> sudo NODE_ENV=production next start -p 3000
The module 'react' was not found. Next.js requires that you include it in 'dependencies' of your 'package.json'. To add it, run 'npm install react'
The module 'react-dom' was not found. Next.js requires that you include it in 'dependencies' of your 'package.json'. To add it, run 'npm install react-dom'
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
Error: Cannot find module 'react'
Require stack:
- /usr/lib/node_modules/next/dist/server/render.js
- /usr/lib/node_modules/next/dist/server/next-server.js
- /usr/lib/node_modules/next/dist/server/next.js
- /usr/lib/node_modules/next/dist/server/lib/start-server.js
- /usr/lib/node_modules/next/dist/cli/next-start.js
- /usr/lib/node_modules/next/dist/lib/commands.js
- /usr/lib/node_modules/next/dist/bin/next
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.mod._resolveFilename (/usr/lib/node_modules/next/dist/build/webpack/require-hook.js:23:32)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:101:18)
at Object.<anonymous> (/usr/lib/node_modules/next/dist/server/render.js:6:37)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/lib/node_modules/next/dist/server/render.js',
'/usr/lib/node_modules/next/dist/server/next-server.js',
'/usr/lib/node_modules/next/dist/server/next.js',
'/usr/lib/node_modules/next/dist/server/lib/start-server.js',
'/usr/lib/node_modules/next/dist/cli/next-start.js',
'/usr/lib/node_modules/next/dist/lib/commands.js',
'/usr/lib/node_modules/next/dist/bin/next'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! front@1.0.0 start: `sudo NODE_ENV=production next start -p 3000`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the front@1.0.0 start 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/ubuntu/.npm/_logs/2022-12-26T13_13_00_876Z-debug.logmodule not found 다른 stack에서 에러가 발생하기 시작했습니다 ㅠ
어제도 module not found에서 저렇게 에러가 발생해서 git으로 pull도해보고 삭제후 다시 설치를 해보고 했는데 안되더라구요...
어벙리벙
질문자
npm i로 설치 완료했고 혹시 몰라서 sudo npm i 로도 설치를 완료한 상태입니다..
ssh환경에서 build이 안돼서 로컬로 build한 후에 git을 통해서 전달했는데 이부분이 문제가 되지는 않는건가요?
제로초(조현영)
지식공유자
/usr/lib/node_modules/next/dist/server/render.js
라는 엉뚱한 경로에서 실행되고 있네요.
sudo NODE_ENV=production npx next start -p 3000
해보세요.어벙리벙
질문자
계속 같은 에러가 발생합니다 ㅠㅜ
ubuntu@ip-172-31-36-77:~/TypeScript_SNS/front$ sudo npm start
> front@1.0.0 start /home/ubuntu/TypeScript_SNS/front
> sudo NODE_ENV=production npx next start -p 3000
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
Error: Cannot find module '/home/ubuntu/TypeScript_SNS/front/.next/prerender-manifest.json'
Require stack:
- /usr/lib/node_modules/next/dist/server/next-server.js
- /usr/lib/node_modules/next/dist/server/next.js
- /usr/lib/node_modules/next/dist/server/lib/start-server.js
- /usr/lib/node_modules/next/dist/cli/next-start.js
- /usr/lib/node_modules/next/dist/lib/commands.js
- /usr/lib/node_modules/next/dist/bin/next
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.mod._resolveFilename (/usr/lib/node_modules/next/dist/build/webpack/require-hook.js:23:32)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:101:18)
at NextNodeServer.getPrerenderManifest (/usr/lib/node_modules/next/dist/server/next-server.js:1362:26)
at NextNodeServer.getPreviewProps (/usr/lib/node_modules/next/dist/server/base-server.js:348:21)
at new Server (/usr/lib/node_modules/next/dist/server/base-server.js:70:32)
at new NextNodeServer (/usr/lib/node_modules/next/dist/server/next-server.js:68:9)
at NextServer.createServer (/usr/lib/node_modules/next/dist/server/next.js:143:16) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/lib/node_modules/next/dist/server/next-server.js',
'/usr/lib/node_modules/next/dist/server/next.js',
'/usr/lib/node_modules/next/dist/server/lib/start-server.js',
'/usr/lib/node_modules/next/dist/cli/next-start.js',
'/usr/lib/node_modules/next/dist/lib/commands.js',
'/usr/lib/node_modules/next/dist/bin/next'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! front@1.0.0 start: `sudo NODE_ENV=production npx next start -p 3000`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the front@1.0.0 start 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/ubuntu/.npm/_logs/2022-12-27T08_06_14_313Z-debug.log





aws에서도 설정을 추가적으로 해야하는 부분이 있을까요?
front 3000포트 back 3005포트를 사용하려하는데
위 사진처럼 aws에서 3000하고 3005포트를 열어주었고
back > app.js
front > package.json
위처럼 설정을 해줬는데 진행이 안되는데 여기서 어느 부분을 수정해야 할까요..