nuxt로 코를 긁을 때 해결까지의 궤적

문제 발생



htps : // 그럼. 없는 xtjs. 오 rg / guede / in s taichion
본가의 설치를 참고로 nuxt를 조금씩 설치했다.
$ npm run dev

그래서 http://localhost:3000/을 시작하려고하면
SyntaxError: Unexpected token ...
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:533:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/{ユーザー名}/private/nuxt/node_modules/@nuxt/cli/dist/cli-command.js:32:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `nuxt`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] dev 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!     /Users/{ユーザー名}/.npm/_logs/2019-09-05T09_19_48_002Z-debug.log

그리고 오류가 발생했습니다 ...

네,, (수수께끼)

과정



우선 npm을 최신으로 해보자.


$ npm install -g n
$ sudo n latest

terminal에 입력.

만든 디렉터리를 삭제 npx create-nuxt-app nuxt 다시.
dyld: initializer function 0x0 not in mapped image for /usr/local/bin/node

Abort trap: 6

해결되지 않았다.

조금 더 컴팩트하게 거부된다.
구그 하면 다이렉트에 히트 하는 것은 없었지만, brew 탓..??
그리고 분위기에서 느껴졌다.

brew에 문제가 있는지 확인


$ brew doctor

terminal에 입력.
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

Warning: Your Xcode is configured with an invalid path.
You should change it to the correct path:
  sudo xcode-select -switch /Applications/Xcode.app

xcode 주변에서 몇 가지 오류가 발생했습니다.
오류가 사라질 때까지 brew doctor로 확인하면서 해결해 나간다.

↓↓↓
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
  /Users/{ユーザー名}/.rbenv/shims/passenger-config

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
  /usr/local/include/node/js_native_api.h
  /usr/local/include/node/js_native_api_types.h
  /usr/local/include/node/libplatform/libplatform-export.h
  /usr/local/include/node/libplatform/libplatform.h
  /usr/local/include/node/libplatform/v8-tracing.h

결국 이런 에러가 남아 버렸다.
node,node,node... 라고 계속되고 있으므로 homebrew로 관리하고 있는 node.js에 관계가 있을 것 같다.

node.js 주변 해결


$ node -v
dyld: initializer function 0x0 not in mapped image for /usr/local/bin/node

Abort trap: 6

눈에 띄는 오류. 역시 이녀석이 원인. .
$ brew reinstall node
{{{中略}}}
icu4c is keg-only, which means it was not symlinked into /usr/local,
because macOS provides libicucore.dylib (but nothing else).

If you need to have icu4c first in your PATH run:
  echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
  echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile

For compilers to find icu4c you may need to set:
  export LDFLAGS="-L/usr/local/opt/icu4c/lib"
  export CPPFLAGS="-I/usr/local/opt/icu4c/include"

For pkg-config to find icu4c you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"

어떻게 다시 설치하려고하면 다시 오류
htps: //코데쵸 rd. 코 m/2018/09/소치온_후우 r_php_에로 r_아 f r_우 pg등에서_ 칭찬해라 w/
↑에 의하면, 그러한 에러가 발생하는 경우도 있다고. 이번에는 오류 메시지와 같이 .bash_profile에 두 개의 환경 변수를 추가합니다.

그리고 다시 reinstall.
cp: /usr/local/Cellar/node/./12.9.1/bin/node: Permission denied
cp: /usr/local/Cellar/node/./12.9.1/lib/dtrace/node.d: Permission denied

어떻게 다시 설치하려고하면 다시 오류

permission을 변경합니다. mojave 환경이기 때문에/usr/local/권한을 변경할 수 없으므로 sudo chown -R $(whoami) /usr/local/Cellar/
그리고 다시 reinstall.
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local

어떻게 다시 설치하려고하면 다시 오류
brew link 할 수 없으면. 기존 파일이 있기 때문에 잘 할 수없는 것 같습니다.
다시 넣기 전에 제거하면 좋았을까. .

이 파일 주위에 꽤 깔끔하지 않기 때문에
$ brew link --overwrite node

그래서, 한꺼번에 해결.
$ node -v
v12.9.1

그래, 해결했다.

해결


$ npx create-nuxt-app nuxt
npx: 341個のパッケージを20.599秒でインストールしました。
$ npm run dev
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/{ユーザー名}/learn/nuxt/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/{ユーザー名}/learn/nuxt/package.jso
n'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/{ユーザー名}/.npm/_logs/2019-09-05T11_01_20_408Z-debug.log

죄송합니다..! ! ?

.. 아, 현재 디렉토리가 잘못되었습니다.
$ cd nuxt/
$ npm run dev

위를 두드리면,



축하합니다..

http://localhost:3000/ 을 열어 본다.



키타ーーーーーーー\(^o^)/

해결했습니다! ! !

요약



즉, 이번에는 $ npm run dev
  • homebrew 내부에 문제가 발생했습니다
  • 설치중인 node.js에 문제가있었습니다.

    의 2개라고 생각합니다.
    소감으로는 MacOS를 mojave로 업그레이드했는데도 원인이 있을 것 같습니다.
    $ homebrew doctor
    $ brew reinstall node
    

    의 2개의 커멘드가 해결에 연결되었습니다!!
  • 좋은 웹페이지 즐겨찾기