node.js

since 2013-06-07

macports だと:

sudo port install nodejs
sudo port install npm

jslint の派生版 jshint を入れる:

sudo npm install -g jshint

Ubuntu に入れる:

$ ./configure
$ make
$ sudo make install
# v0.10.22 を入れたら /usr/local/bin/npm も入っていた。  

パッケージで入れる:

  sudo apt-get install nodejs
  sudo apt-get install npm
  npm config set registry http://registry.npmjs.org/
  sudo npm install -g jshint

http://stackoverflow.com/questions/12913141/installing-from-npm-fails

vagrant@precise64 Ubuntu 12.04.4 だと nodejs も npm もバージョンが古いので注意。

$ node -v
v0.6.12
$ npm -v
1.1.4
$ jshint -v
jshint v2.4.3

xml パーサー

XML パーサーを探したら xml2js を見つけた:

http://d.hatena.ne.jp/zebevogue/20130308/1362707814

https://github.com/Leonidas-from-XIV/node-xml2js

>npm install -g xml2js
npm http GET https://registry.npmjs.org/xml2js
npm http 200 https://registry.npmjs.org/xml2js
npm http GET https://registry.npmjs.org/xml2js/-/xml2js-0.2.8.tgz
npm http 200 https://registry.npmjs.org/xml2js/-/xml2js-0.2.8.tgz
npm http GET https://registry.npmjs.org/sax
npm http 200 https://registry.npmjs.org/sax
npm http GET https://registry.npmjs.org/sax/-/sax-0.5.5.tgz
npm http 200 https://registry.npmjs.org/sax/-/sax-0.5.5.tgz
npm WARN package.json dateformat@1.0.2-1.2.3 No repository field.
npm WARN package.json istanbul@0.1.22 No repository field.
npm WARN package.json pause@0.0.1 No repository field.
npm WARN package.json policyfile@0.0.4 'repositories' (plural) Not supported.
npm WARN package.json Please pick one as the 'repository' field
xml2js@0.2.8 C:\Users\nishimotz\AppData\Roaming\npm\node_modules\xml2js
└── sax@0.5.5

xml2json というものもあった:

https://github.com/buglabs/node-xml2json

Windows 8 に xml2json を入れようとして Windows SDK 7.1 Command Prompt から下記を実行したらうまくいった。

npm install -g xml2json

Windows SDK が動かないコマンドプロンプトだと node-expat で下記のエラーになる:

(前略)
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBu
ild.targets(297,5): warning MSB8003: Could not find WindowsSDKDir
 variable from the registry.  TargetFrameworkVersion or PlatformT
oolset may be set to an invalid version number. [C:\Users\nishimo
tz\AppData\Roaming\npm\node_modules\xml2json\node_modules\node-ex
pat\build\deps\libexpat\expat.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\M
icrosoft.Cpp.x64.targets(146,5): error MSB6006: "CL.exe" はコード
-10
73741701 を伴って終了しました。 [C:\Users\nishimotz\AppData\Roamin
g\npm\node
_modules\xml2json\node_modules\node-expat\build\deps\libexpat\exp
at.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.303
19\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs
\node_modules\npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98
:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_p
rocess.js:789:12)
gyp ERR! System Windows_NT 6.2.9200
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\
npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\nishimotz\AppData\Roaming\npm\node_modules\x
ml2json\node_modules\node-expat
gyp ERR! node -v v0.10.10
gyp ERR! node-gyp -v v0.9.6
gyp ERR! not ok
npm ERR! weird error 1
npm ERR! not ok code 0

jQuery

jQuery も Windows SDK が必要だった。。

C:\Program Files\Microsoft SDKs\Windows\v7.1>npm install -g jquery
(中略)
jquery@1.8.3 C:\Users\nishimotz\AppData\Roaming\npm\node_modules\jquery
├── location@0.0.1
├── navigator@1.0.1
├── xmlhttprequest@1.4.2
├── htmlparser@1.7.6
├── contextify@0.1.6 (bindings@1.1.1)
└── jsdom@0.2.19 (cssom@0.2.5, cssstyle@0.2.3, request@2.27.0)

NODE_PATH

Windows では NODE_PATH 環境変数の設定が必要という話

http://tmlife.net/programming/javascript/npm-node-js-require-module-memo.html

http://sucrose.hatenablog.com/entry/20120315/p1

set NODE_PATH=C:\Users\nishimotz\AppData\Roaming\npm\node_modules

nodejs.txt · 最終更新: 2014/02/13 09:46 by Takuya Nishimoto
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0