npm으로 npm의 버전을 업데이트 할 때의 명령어는 다음과 같다.
$ npm install -g npm
업데이트 명령 실행 후 오류가 발생한 뒤 npm 명령어가 없다는 경우가 생길 수 있다. 당황하지 말고 아래 명령어를 실행한다.
# 캐시 강제 삭제
$ npm cache clean -f
# npm 다운로드
$ curl http://npmjs.org/install.sh | sh
다시 npm이 설치되어 npm 명령어를 실행할 수 있다.
npm으로 npm의 버전을 업데이트 할 때의 명령어는 다음과 같다.
$ npm install -g npm
업데이트 명령 실행 후 오류가 발생한 뒤 npm 명령어가 없다는 경우가 생길 수 있다. 당황하지 말고 아래 명령어를 실행한다.
# 캐시 강제 삭제
$ npm cache clean -f
# npm 다운로드
$ curl http://npmjs.org/install.sh | sh
다시 npm이 설치되어 npm 명령어를 실행할 수 있다.
앵귤러 또는 다른 브라우저에 필요한 스크립트를 npm 으로 설치하고 node_modules 안에 있는 스크립트로 참조하고 싶을 때 다음과 같이 라우팅을 추가한다.
// scripts 경로로 접근시 node_modules을 사용할 수 있게 설정
app.use("/scripts", express.static(path.join(__dirname, "node_modules")));
<!-- 결과 -->
<script src="/scripts/angular/angular.min.js"></script>
mariasql package 설치 명령어 실행시 오류를 내뿜으며 node-debug.log 를 확인하라고 명령어가 나올 경우 아래와 같이 하면 된다.
debug log 에는 node-gyp rebuild 를 하라고 나오는데, 이 오류메세지와는 아무 관련이 없다.
윈도우에 Python 2.7 버전이 설치되어있지 않으면 설치해야한다. 파이썬 2 이상 3 미만 버전을 쓰면 되는데, 2.7 을 강조하니 쓰자.
여기서 다운로드 한다. 설치시 Window PATH 등록 옵션을 꼭 선택해야한다.
$ npm config set python "/the/python/path" --global
the/python/path 에 자신의 python 설치 경로를 넣어주자.
왜 VS 2015 를 설치해야하지? 라고 생각이 들텐데, Visual C++을 사용하기 때문이다.
여기서 다운로드한다. 설치시 프로그래밍언어 탭에서 Visual C++을 꼭 선택해서 설치해야한다.
기존에 VS2015 가 설치되어있는 경우, 프로그램 추가/삭제에서 선택 후 수정 메뉴를 눌러 Visual C++ 옵션을 추가한 뒤 업데이트해준다.
2017 년 기준 위 링크가 만료되어 cpp-build-tools를 설치해야한다
$ npm config set msvs_version "2015" --global
$ npm install mariasql --save
Windows10 에서 mariasql package 설치시 C++ 컴파일이 필요하니, VS2015 로 C++ 컴파일러를 설치해야된다라는 걸 msdn 이나 npm 에 친절히 남겨줬으면 이렇게까지 시간을 날리지 않았을텐데...
빠르고 위의 오류가 절대 발생하지 않는 mysql2 패키지를 사용하면 된다.
mongoose-post-find 모듈 사용시 bson 라이브러리를 찾지 못해 설치가 안되는 경우가 있다.
{ Error: Cannot find module '../build/Release/bson'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
// 여기서 오류가 발생한다
at Object.<anonymous> (your project\mongoose-post-find\node_modules\bson\ext\index.js:15:10)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (your project\mongoose-post-find\node_modules\bson\lib\bson\index.js:3:24)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32) code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
해당 패키지 경로의 15번째 줄을 따라가보면 bson 패키지의 경로를 지정해주는 부분이 있는데, 이 부분을 같은 패키지 내의 bson 경로로 일치시켜주면 된다.
var bson = null;
try {
// Load the precompiled win32 binary
if (process.platform == "win32" && process.arch == "x64") {
bson = require("./win32/x64/bson");
} else if (process.platform == "win32" && process.arch == "ia32") {
bson = require("./win32/ia32/bson");
} else {
bson = require("../build/Release/bson");
}
} catch (err) {
// Attempt to load the release bson version
try {
// 여기의 상대경로를 같은 패키지의 bson의 경로로 일치시켜주면 된다.
bson = require("../browser_build/bson");
} catch (err) {
console.dir(err);
console.error(
"js-bson: Failed to load c++ bson extension, using pure JS version"
);
bson = require("../lib/bson/bson");
}
}