苦労の果てに。
前回まで
- http://ytyaru.hatenablog.com/entry/2018/03/24/000000
- http://ytyaru.hatenablog.com/entry/2018/03/25/000000
- http://ytyaru.hatenablog.com/entry/2018/03/26/000000
pugをインストールするためにnode.jsをインストールした。
pugインストール
$ npm install pug
$ npm install pug /home/mint └─┬ pug@2.0.0-rc.1 ├─┬ pug-code-gen@1.1.1 │ ├─┬ constantinople@3.1.0 │ │ ├── acorn@3.3.0 │ │ └── is-expression@2.1.0 │ ├── doctypes@1.1.0 │ ├── js-stringify@1.0.2 │ ├── pug-attrs@2.0.2 │ ├── pug-error@1.3.2 │ ├── void-elements@2.0.1 │ └─┬ with@5.1.1 │ └─┬ acorn-globals@3.1.0 │ └── acorn@4.0.11 ├─┬ pug-filters@2.1.2 │ ├─┬ clean-css@3.4.26 │ │ ├─┬ commander@2.8.1 │ │ │ └── graceful-readlink@1.0.1 │ │ └─┬ source-map@0.4.4 │ │ └── amdefine@1.0.1 │ ├─┬ jstransformer@1.0.0 │ │ ├── is-promise@2.1.0 │ │ └─┬ promise@7.1.1 │ │ └── asap@2.0.5 │ ├── pug-walk@1.1.2 │ ├─┬ resolve@1.3.3 │ │ └── path-parse@1.0.5 │ └─┬ uglify-js@2.8.26 │ ├── source-map@0.5.6 │ ├── uglify-to-browserify@1.0.2 │ └─┬ yargs@3.10.0 │ ├── camelcase@1.2.1 │ ├─┬ cliui@2.1.0 │ │ ├─┬ center-align@0.1.3 │ │ │ ├─┬ align-text@0.1.4 │ │ │ │ ├─┬ kind-of@3.2.2 │ │ │ │ │ └── is-buffer@1.1.5 │ │ │ │ ├── longest@1.0.1 │ │ │ │ └── repeat-string@1.6.1 │ │ │ └── lazy-cache@1.0.4 │ │ ├── right-align@0.1.3 │ │ └── wordwrap@0.0.2 │ ├── decamelize@1.2.0 │ └── window-size@0.1.0 ├─┬ pug-lexer@3.1.0 │ ├─┬ character-parser@2.2.0 │ │ └─┬ is-regex@1.0.4 │ │ └─┬ has@1.0.1 │ │ └── function-bind@1.1.0 │ └─┬ is-expression@3.0.0 │ └── acorn@4.0.11 ├── pug-linker@3.0.0 ├─┬ pug-load@2.0.6 │ └── object-assign@4.1.1 ├─┬ pug-parser@2.0.2 │ └── token-stream@0.0.1 ├── pug-runtime@2.0.3 └── pug-strip-comments@1.0.2 npm WARN enoent ENOENT: no such file or directory, open '/home/mint/package.json' npm WARN mint No description npm WARN mint No repository field. npm WARN mint No README data npm WARN mint No license field.
$ pug コマンド 'pug' は見つかりませんでした。
なんでや。
npm i pug-cli -g npm WARN checkPermissions Missing write access to /usr/lib/node_modules /usr/lib └─┬ pug-cli@1.0.0-alpha6 ├─┬ chalk@1.1.3 │ ├── ansi-styles@2.2.1 │ ├── escape-string-regexp@1.0.5 │ ├─┬ has-ansi@2.0.0 │ │ └── ansi-regex@2.1.1 │ ├── strip-ansi@3.0.1 │ └── supports-color@2.0.0 ├─┬ commander@2.9.0 │ └── graceful-readlink@1.0.1 ├─┬ mkdirp@0.5.1 │ └── minimist@0.0.8 └─┬ pug@2.0.0-rc.1 ├─┬ pug-code-gen@1.1.1 │ ├─┬ constantinople@3.1.0 │ │ ├── acorn@3.3.0 │ │ └── is-expression@2.1.0 │ ├── doctypes@1.1.0 │ ├── js-stringify@1.0.2 │ ├── pug-attrs@2.0.2 │ ├── pug-error@1.3.2 │ ├── void-elements@2.0.1 │ └─┬ with@5.1.1 │ └─┬ acorn-globals@3.1.0 │ └── acorn@4.0.11 ├─┬ pug-filters@2.1.2 │ ├─┬ clean-css@3.4.26 │ │ ├── commander@2.8.1 │ │ └─┬ source-map@0.4.4 │ │ └── amdefine@1.0.1 │ ├─┬ jstransformer@1.0.0 │ │ ├── is-promise@2.1.0 │ │ └─┬ promise@7.1.1 │ │ └── asap@2.0.5 │ ├── pug-walk@1.1.2 │ ├─┬ resolve@1.3.3 │ │ └── path-parse@1.0.5 │ └─┬ uglify-js@2.8.26 │ ├── source-map@0.5.6 │ ├── uglify-to-browserify@1.0.2 │ └─┬ yargs@3.10.0 │ ├── camelcase@1.2.1 │ ├─┬ cliui@2.1.0 │ │ ├─┬ center-align@0.1.3 │ │ │ ├─┬ align-text@0.1.4 │ │ │ │ ├─┬ kind-of@3.2.2 │ │ │ │ │ └── is-buffer@1.1.5 │ │ │ │ ├── longest@1.0.1 │ │ │ │ └── repeat-string@1.6.1 │ │ │ └── lazy-cache@1.0.4 │ │ ├── right-align@0.1.3 │ │ └── wordwrap@0.0.2 │ ├── decamelize@1.2.0 │ └── window-size@0.1.0 ├─┬ pug-lexer@3.1.0 │ ├─┬ character-parser@2.2.0 │ │ └─┬ is-regex@1.0.4 │ │ └─┬ has@1.0.1 │ │ └── function-bind@1.1.0 │ └─┬ is-expression@3.0.0 │ └── acorn@4.0.11 ├── pug-linker@3.0.0 ├─┬ pug-load@2.0.6 │ └── object-assign@4.1.1 ├─┬ pug-parser@2.0.2 │ └── token-stream@0.0.1 ├── pug-runtime@2.0.3 └── pug-strip-comments@1.0.2 npm ERR! Linux 3.19.0-32-generic npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "i" "pug-cli" "-g" npm ERR! node v6.10.3 npm ERR! npm v3.10.10 npm ERR! path /usr/lib/node_modules npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall access npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules' npm ERR! at Error (native) npm ERR! { Error: EACCES: permission denied, access '/usr/lib/node_modules' npm ERR! at Error (native) npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'access', npm ERR! path: '/usr/lib/node_modules' } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! Please include the following file with any support request: npm ERR! /home/mint/npm-debug.log
エラー…。
調べてみた。
エラーメッセージそのままでググった。
npm WARN enoent ENOENT: no such file or directory, open '/home/mint/package.json'
どうやらWARNはほぼ正常らしい。
インストール場所
カレントディレクトリ
npm install パッケージ名
システムディレクトリ
npm install -g パッケージ名
再挑戦
npm install -g pug
今度は-g
でグローバルへインストールする。
$ npm install -g pug npm WARN checkPermissions Missing write access to /usr/lib/node_modules /usr/lib └─┬ pug@2.0.0-rc.1 ├─┬ pug-code-gen@1.1.1 │ ├─┬ constantinople@3.1.0 │ │ ├── acorn@3.3.0 │ │ └── is-expression@2.1.0 │ ├── doctypes@1.1.0 │ ├── js-stringify@1.0.2 │ ├── pug-attrs@2.0.2 │ ├── pug-error@1.3.2 │ ├── void-elements@2.0.1 │ └─┬ with@5.1.1 │ └─┬ acorn-globals@3.1.0 │ └── acorn@4.0.11 ├─┬ pug-filters@2.1.2 │ ├─┬ clean-css@3.4.26 │ │ ├─┬ commander@2.8.1 │ │ │ └── graceful-readlink@1.0.1 │ │ └─┬ source-map@0.4.4 │ │ └── amdefine@1.0.1 │ ├─┬ jstransformer@1.0.0 │ │ ├── is-promise@2.1.0 │ │ └─┬ promise@7.1.1 │ │ └── asap@2.0.5 │ ├── pug-walk@1.1.2 │ ├─┬ resolve@1.3.3 │ │ └── path-parse@1.0.5 │ └─┬ uglify-js@2.8.26 │ ├── source-map@0.5.6 │ ├── uglify-to-browserify@1.0.2 │ └─┬ yargs@3.10.0 │ ├── camelcase@1.2.1 │ ├─┬ cliui@2.1.0 │ │ ├─┬ center-align@0.1.3 │ │ │ ├─┬ align-text@0.1.4 │ │ │ │ ├─┬ kind-of@3.2.2 │ │ │ │ │ └── is-buffer@1.1.5 │ │ │ │ ├── longest@1.0.1 │ │ │ │ └── repeat-string@1.6.1 │ │ │ └── lazy-cache@1.0.4 │ │ ├── right-align@0.1.3 │ │ └── wordwrap@0.0.2 │ ├── decamelize@1.2.0 │ └── window-size@0.1.0 ├─┬ pug-lexer@3.1.0 │ ├─┬ character-parser@2.2.0 │ │ └─┬ is-regex@1.0.4 │ │ └─┬ has@1.0.1 │ │ └── function-bind@1.1.0 │ └─┬ is-expression@3.0.0 │ └── acorn@4.0.11 ├── pug-linker@3.0.0 ├─┬ pug-load@2.0.6 │ └── object-assign@4.1.1 ├─┬ pug-parser@2.0.2 │ └── token-stream@0.0.1 ├── pug-runtime@2.0.3 └── pug-strip-comments@1.0.2 npm ERR! Linux 3.19.0-32-generic npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "pug" npm ERR! node v6.10.3 npm ERR! npm v3.10.10 npm ERR! path /usr/lib/node_modules npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall access npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules' npm ERR! at Error (native) npm ERR! { Error: EACCES: permission denied, access '/usr/lib/node_modules' npm ERR! at Error (native) npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'access', npm ERR! path: '/usr/lib/node_modules' } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! Please include the following file with any support request: npm ERR! /home/mint/npm-debug.log
パーミッションエラー。
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npmでpermission deniedになった時の対処法[mac] - Qiita
なんか面倒くさいので外付HDDにローカルで保存することにする。
ローカル保存
テキトーなパスに移動。
npm install pug
$ pug -v コマンド 'pug' は見つかりませんでした。
そもそもpugコマンドがどこにあるのか不明。
npm i pug-cli
./node_modules/.bin/pug
があった
しかし、カレントディレクトリをそこに移動してpug
コマンドを叩いても
..../node_modules/.bin $ pug -v コマンド 'pug' は見つかりませんでした。
どうすれば実行できるのか謎。
パス変更
npmでpermission deniedになった時の対処法[mac] - Qiita
- ディレクトリ作成
/media/mint/85f78c06-a96e-4020-ac36-9419b7e456db/mint/root/tools/nodejs/npm_global
npm config set prefix '/media/mint/85f78c06-a96e-4020-ac36-9419b7e456db/mint/root/tools/nodejs/npm_global'
~/.bash_profile
にexport PATH=/media/mint/85f78c06-a96e-4020-ac36-9419b7e456db/mint/root/tools/nodejs/npm_global/bin:$PATH
追加。source ~/.profile
インストール
$ npm install -g pug $ npm install -g pug npm ERR! not a package /.../nodejs/node_modules/.bin/pug npm ERR! addLocal Could not install /.../nodejs/node_modules/.bin/pug npm ERR! Linux 3.19.0-32-generic npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "pug" npm ERR! node v6.10.3 npm ERR! npm v3.10.10 npm ERR! path /tmp/npm-17702-5d35792b/unpack-cfac593e/package.json npm ERR! code ENOENT npm ERR! errno -2 npm ERR! syscall open npm ERR! enoent ENOENT: no such file or directory, open '/tmp/npm-17702-5d35792b/unpack-cfac593e/package.json' npm ERR! enoent ENOENT: no such file or directory, open '/tmp/npm-17702-5d35792b/unpack-cfac593e/package.json' npm ERR! enoent This is most likely not a problem with npm itself npm ERR! enoent and is related to npm not being able to find a file. npm ERR! enoent npm ERR! Please include the following file with any support request: npm ERR! /.../nodejs/node_modules/.bin/npm-debug.log
/.../nodejs/node_modules/.bin $ npm install -g pug-cli /.../nodejs/npm_global/bin/pug -> /.../nodejs/npm_global/lib/node_modules/pug-cli/index.js /.../nodejs/npm_global/lib └─┬ pug-cli@1.0.0-alpha6 ├─┬ chalk@1.1.3 │ ├── ansi-styles@2.2.1 │ ├── escape-string-regexp@1.0.5 │ ├─┬ has-ansi@2.0.0 │ │ └── ansi-regex@2.1.1 │ ├── strip-ansi@3.0.1 │ └── supports-color@2.0.0 ├─┬ commander@2.9.0 │ └── graceful-readlink@1.0.1 ├─┬ mkdirp@0.5.1 │ └── minimist@0.0.8 └─┬ pug@2.0.0-rc.1 ├─┬ pug-code-gen@1.1.1 │ ├─┬ constantinople@3.1.0 │ │ ├── acorn@3.3.0 │ │ └── is-expression@2.1.0 │ ├── doctypes@1.1.0 │ ├── js-stringify@1.0.2 │ ├── pug-attrs@2.0.2 │ ├── pug-error@1.3.2 │ ├── void-elements@2.0.1 │ └─┬ with@5.1.1 │ └─┬ acorn-globals@3.1.0 │ └── acorn@4.0.11 ├─┬ pug-filters@2.1.2 │ ├─┬ clean-css@3.4.26 │ │ ├── commander@2.8.1 │ │ └─┬ source-map@0.4.4 │ │ └── amdefine@1.0.1 │ ├─┬ jstransformer@1.0.0 │ │ ├── is-promise@2.1.0 │ │ └─┬ promise@7.1.1 │ │ └── asap@2.0.5 │ ├── pug-walk@1.1.2 │ ├─┬ resolve@1.3.3 │ │ └── path-parse@1.0.5 │ └─┬ uglify-js@2.8.26 │ ├── source-map@0.5.6 │ ├── uglify-to-browserify@1.0.2 │ └─┬ yargs@3.10.0 │ ├── camelcase@1.2.1 │ ├─┬ cliui@2.1.0 │ │ ├─┬ center-align@0.1.3 │ │ │ ├─┬ align-text@0.1.4 │ │ │ │ ├─┬ kind-of@3.2.2 │ │ │ │ │ └── is-buffer@1.1.5 │ │ │ │ ├── longest@1.0.1 │ │ │ │ └── repeat-string@1.6.1 │ │ │ └── lazy-cache@1.0.4 │ │ ├── right-align@0.1.3 │ │ └── wordwrap@0.0.2 │ ├── decamelize@1.2.0 │ └── window-size@0.1.0 ├─┬ pug-lexer@3.1.0 │ ├─┬ character-parser@2.2.0 │ │ └─┬ is-regex@1.0.4 │ │ └─┬ has@1.0.1 │ │ └── function-bind@1.1.0 │ └─┬ is-expression@3.0.0 │ └── acorn@4.0.11 ├── pug-linker@3.0.0 ├─┬ pug-load@2.0.6 │ └── object-assign@4.1.1 ├─┬ pug-parser@2.0.2 │ └── token-stream@0.0.1 ├── pug-runtime@2.0.3 └── pug-strip-comments@1.0.2
なぜかpug-cli
ならインストールできたらしい。
$ pug -V
pug version: 2.0.0-rc.1
pug-cli version: 1.0.0-alpha6
まとめ
bash -l pug -V
次回からはこのコマンドでpugを実行可能。(しかし、設定済みの rbenv, pyenv まで同時に起動してしまい重くなる)
所感
ゴリラでも分かるらしいが私には分からない。私はゴリラ未満のようだ。
pugどころか、それ以前のインストールでつまづく。いつものことながら環境構築が最大の難関。