CRA(Create React App)로 만든 Application에서 저장소에 커밋하고 내려받을 때 /node_modules/.bin 파일들의 심볼릭 링크가 사라져서, react-script가 실행되지 않는 오류가 발생했다.
그래서, 직접 경로를 지정해 주었다.
// package.json
{
"scripts": {
"start": "export PORT=8080 && node_modules/react-scripts/bin/react-scripts.js start",
...
}
}
하지만 조치해주었음에도 불구하고 아래와 같이 xdg-open 에러가 발생했다.
$ npm start
Starting the development server...
node:events:505
throw er; // Unhandled 'error' event
^
Error: spawn xdg-open ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn xdg-open',
path: 'xdg-open',
spawnargs: [ 'http://localhost:8080' ]
}
여기서 발생한 xdg-open은 리액트 프로젝트가 시작될 때 자동으로 브라우저가 켜지게끔 해주는 파일인데, 현재 프로젝트가 실행시키는 서버가 따로 있다보니 브라우저를 켤 수 있는 환경이 아니라서 문제가 발생한 것 같았다. (ex. BROWSER=google-chrome)
그래서 아래와 같이 수정했고, 정상적으로 출력되는 것을 확인할 수 있었다.
$ export BROWSER=none
또는 .env 파일을 적용할 수 있다.
# .env (Root에 존재)
BROWSER=none
CRA(Create React App)로 만든 Application에서 저장소에 커밋하고 내려받을 때 /node_modules/.bin 파일들의 심볼릭 링크가 사라져서, react-script가 실행되지 않는 오류가 발생했다.
그래서, 직접 경로를 지정해 주었다.
// package.json
{
"scripts": {
"start": "export PORT=8080 && node_modules/react-scripts/bin/react-scripts.js start",
...
}
}
하지만 조치해주었음에도 불구하고 아래와 같이 xdg-open 에러가 발생했다.
$ npm start
Starting the development server...
node:events:505
throw er; // Unhandled 'error' event
^
Error: spawn xdg-open ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn xdg-open',
path: 'xdg-open',
spawnargs: [ 'http://localhost:8080' ]
}
여기서 발생한 xdg-open은 리액트 프로젝트가 시작될 때 자동으로 브라우저가 켜지게끔 해주는 파일인데, 현재 프로젝트가 실행시키는 서버가 따로 있다보니 브라우저를 켤 수 있는 환경이 아니라서 문제가 발생한 것 같았다. (ex. BROWSER=google-chrome)
그래서 아래와 같이 수정했고, 정상적으로 출력되는 것을 확인할 수 있었다.
$ export BROWSER=none
또는 .env 파일을 적용할 수 있다.
# .env (Root에 존재)
BROWSER=none