前回質問した問題がいまだに解決しないので再度整理して質問させてください。
npmエラーzsh: command not found: gulpの対処法
シンプルに任意フォルダ配下でgulpの実行環境を作成してみる
json
1$nodeバージョン確認 2$ node -v 3v8.8.1 4 5# 任意フォルダ 6cd GulpSample 7 8# GulpSampleフォルダ配下にgulpをインストール 9$ npm install gulp --save-dev 10 11# gulpバージョン確認 12# ~~~~~~~~~~前回より解決していないPATHの問題~~~~~~~~~~ 13$ gulp -v 14zsh: command not found: gulp 15 16# PATHの確認 17$ echo $PATH 18/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin 19 20# 21$ npm bin -g 22/usr/local/bin 23 24# 存在確認 25$ ls $(npm bin -g) 26gulp 27 28ローカルgulp確認 29$ ls ltr /usr/local/bin/gulp 30gulp -> ../lib/node_modules/gulp/bin/gulp.js 31 32# gulpグローバルインストール 33$ npm install -g gulp 34npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue 35npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue 36npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree. 37/usr/local/bin/gulp -> /usr/local/lib/node_modules/gulp/bin/gulp.js 38npm ERR! path /usr/local/share/man/man1/gulp.1 39npm ERR! code EEXIST 40npm ERR! Refusing to delete /usr/local/share/man/man1/gulp.1: ../../../lib/node_modules/gulp-cli/gulp.1 symlink target is not controlled by npm /usr/local/share/man/man1 41npm ERR! File exists: /usr/local/share/man/man1/gulp.1 42npm ERR! Move it away, and try again. 43 44npm ERR! A complete log of this run can be found in: 45npm ERR! /Users/ユーザー名/.npm/_logs/2018-01-23T00_49_47_044Z-debug.log
前回ご回答いただきました、【プチ加筆】応用編、ローカルを上手く使うまでの対策を行っていれば、グローバルインストールを用いてのGulp実行はできるはずですが、できておりません。
備考 npx gulp
のやり方で行えば実行可能
下記サイトでは何度かお世話になっており、一からなぞってやってみましたが、問題なくできます。
こちらでも--save-dev
などを使用しており、グローバルでなく、ローカルでインストールしていくやり方のようです。
これまでのやり方だと、gulp scss
など、gulpfils.jsにscssタスクを記載していても、おそらくPATHの問題?でエラーとなっていましたが、下記サイトのやり方ではnpx gulp
として実行されています。
解決したいこととしては、gulp scss
などとしても実行してみたいです。
また、実行法は複数あるようなのですが、どのやり方がスタンダードなのでしょうか?
絶対つまずかないGulp入門。インストールからSassのコンパイルまで
前回の質問と重複しがちですが、整理がつかなくなってしまい、再度質問とさせていただきました。
よろしくお願いいたします。
質問追記1/23
json
1{ 2 "name": "GulpSample", 3 "version": "1.0.0", 4 "description": "", 5 "main": "index.js", 6 "scripts": { 7 "test": "echo \"Error: no test specified\" && exit 1", 8 "build": "gulp" // scripts内は node_modules/.bin のディレクトリを見てくれるため、省略ができます 追記 9 }, 10 "keywords": [], 11 "author": "", 12 "license": "ISC", 13 "devDependencies": { 14 "gulp": "^3.9.1", 15 "gulp-sass": "^3.1.0" 16 } 17} 18
質問1
1-2. npm run-scriptと組み合わせる
毎回"build": "gulp"
をpackage.jsonに追加する流れで大丈夫でしょうか?
質問2
インストール方法ですが、覚えていないのですが、検索してなぞってやった記憶はあります。
下記which nodeの実行結果です。
json
1$ which node 2/usr/local/bin/node 3 4$ brew list node 5/usr/local/Cellar/node/8.5.0/bin/node 6/usr/local/Cellar/node/8.5.0/etc/bash_completion.d/npm 7/usr/local/Cellar/node/8.5.0/include/node/ (136 files) 8/usr/local/Cellar/node/8.5.0/lib/dtrace/node.d 9/usr/local/Cellar/node/8.5.0/libexec/bin/ (2 files) 10/usr/local/Cellar/node/8.5.0/libexec/lib/ (4000 files) 11/usr/local/Cellar/node/8.5.0/share/doc/ (3 files) 12/usr/local/Cellar/node/8.5.0/share/man/man1/node.1 13/usr/local/Cellar/node/8.5.0/share/systemtap/tapset/node.stp
一度アドバイスいただきましたやり方で再度node.jsをインストールしてみたいと思います。
また、実行結果を記載いたします。
node.jsアンインストールしようと下記サイトを参考にしたところ、どうやらbrewでインストールしているようでした。
上記のようにbrew list node
としnodeが確認できました。
node.jsをアンインストールしたい
brew uninstall node
のエラー文追記
bash
1Error: Refusing to uninstall /usr/local/Cellar/node/8.5.0 2because it is required by yarn 1.0.2, which is currently installed. 3You can override this and force removal with: 4 brew uninstall --ignore-dependencies node
追記1/24
json
1// シンボリックリンク 2[$] ls -l /usr/local/bin/brew 3lrwxr-xr-x 1 ユーザー名 admin 28 7 24 2017 /usr/local/bin/brew -> /usr/local/Homebrew/bin/brew 4 5// brew自体の権限と所有者権限 6[$] ls -l /usr/local/Homebrew/bin/brew 7-rwxr-xr-x 1 ユーザー名 admin 2548 1 3 19:07 /usr/local/Homebrew/bin/brew // 返り値赤文字 8 9// brewでインストールされたものの権限と所有者情報 10[$] ls -l /usr/local/bin/node 11-rwxrwxr-x 1 ユーザー名 admin 35731472 10 29 16:44 /usr/local/bin/node // 返り値赤文字 12 13// 配下ディレクトリのCellerの権限と所有者情報 14[$] ls -l /usr/local 15total 0 16drwxrwxr-x 25 ユーザー名 admin 800 11 19 10:10 Cellar 17drwxrwxr-x 3 ユーザー名 admin 96 11 19 10:10 Frameworks 18drwxrwxr-x 17 ユーザー名 admin 544 1 3 19:07 Homebrew 19drwxrwxr-x 145 ユーザー名 admin 4640 1 22 02:15 bin 20drwxrwxr-x 6 ユーザー名 admin 192 11 19 10:09 etc 21drwxr-xr-x 11 root wheel 352 11 19 10:10 git 22drwxrwxr-x 12 ユーザー名 admin 384 11 19 10:10 include 23drwxrwxr-x 33 ユーザー名 admin 1056 11 19 10:10 lib 24lrwxr-xr-x 1 root wheel 30 7 24 2017 mysql -> mysql-5.7.19-macos10.12-x86_64 25drwxr-xr-x 3 root wheel 96 11 19 10:09 n 26drwxrwxr-x 37 ユーザー名 admin 1184 11 19 10:10 opt 27drwxr-xr-x 3 root wheel 96 11 19 10:10 remotedesktop 28drwxrwxr-x 14 ユーザー名 admin 448 11 19 10:10 share 29drwxr-xr-x 13 ユーザー名 staff 416 11 19 10:10 tomcat 30drwxrwxr-x 5 ユーザー名 admin 160 11 19 10:10 var 31 32// brew自体が持っているbrewの診断ツール 33[$] brew doctor 34Please note that these warnings are just used to help the Homebrew maintainers 35with debugging if you file an issue. If everything you use Homebrew for is 36working fine: please don't worry or file an issue; just ignore this. Thanks! 37 38Warning: You have MacPorts or Fink installed: 39 /opt/local/bin/port 40 41This can cause trouble. You don't have to uninstall them, but you may want to 42temporarily move them out of the way, e.g. 43 44 sudo mv /opt/local ~/macports 45 46Warning: Unbrewed header files were found in /usr/local/include. 47If you didn't put them there on purpose they could cause problems when 48building Homebrew formulae, and may need to be deleted. 49 50Unexpected header files: 51 /usr/local/include/node/android-ifaddrs.h 52 /usr/local/include/node/ares.h 53 /usr/local/include/node/ares_build.h 54 /usr/local/include/node/ares_rules.h 55 /usr/local/include/node/ares_version.h 56 /usr/local/include/node/libplatform/libplatform-export.h 57 /usr/local/include/node/libplatform/libplatform.h 58 /usr/local/include/node/libplatform/v8-tracing.h 59 /usr/local/include/node/nameser.h 60 /usr/local/include/node/node.h 61 /usr/local/include/node/node_api.h 62 /usr/local/include/node/node_api_types.h 63 /usr/local/include/node/node_buffer.h 64 /usr/local/include/node/node_object_wrap.h 65 /usr/local/include/node/node_version.h 66 /usr/local/include/node/openssl/aes.h 67 /usr/local/include/node/openssl/archs/BSD-x86/opensslconf.h 68 // ...以下文字数制限により省略 69 70Warning: You have unlinked kegs in your Cellar 71Leaving kegs unlinked can lead to build-trouble and cause brews that depend on 72those kegs to fail to run properly once built. Run `brew link` on these: 73 node 74 75Warning: Broken symlinks were found. Remove them with `brew prune`: 76 /usr/local/bin/apm 77 /usr/local/bin/atom 78 /usr/local/bin/gulp 79 /usr/local/share/man/man1/gulp.1 80 /usr/local/share/man/man1/npx.1 81 82// OSのビルドバージョン 83[$] sw_vers 84ProductName: Mac OS X 85ProductVersion: 10.13.2 86BuildVersion: 17C205 87macOS High Sierra バージョン 10.13.2
1/24 追記
json
1[$] brew prune 2Pruned 5 symbolic links and 10 directories from /usr/local 3 4[$] brew list 5autoconf node pkg-config ruby yarn 6gdbm openssl python ruby-build zsh 7icu4c openssl@1.1 rbenv sqlite zsh-completions 8jenkins pcre readline tree 9libyaml perl rename vim 10 11[$] brew cask list 12==> Tapping caskroom/cask 13Cloning into '/usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask'... 14 remote: Counting objects: 3993, done. 15remote: Compressing objects: 100% (3970/3970), done. 16remote: Total 3993 (delta 36), reused 618 (delta 19), pack-reused 0 17Receiving objects: 100% (3993/3993), 1.37 MiB | 594.00 KiB/s, done. 18Resolving deltas: 100% (36/36), done. 19Tapped 0 formulae (4,002 files, 4.3MB) 20==> Creating Caskroom at /usr/local/Caskroom 21==> We'll set permissions properly so we won't need sudo in the future
bash
1//追記 2bash-3.2$ sudo find / -name "brew" 3Password: 4find: /private/var/db/ConfigurationProfiles/Store: Operation not permitted 5find: /private/var/folders/js/77b1ttqn6dlgdc3qw57s6_xh0000gn/0/SafariFamily: Operation not permitted 6find: /private/var/folders/js/77b1ttqn6dlgdc3qw57s6_xh0000gn/0/com.apple.LaunchServices.dv: Operation not permitted 7find: /private/var/folders/js/77b1ttqn6dlgdc3qw57s6_xh0000gn/0/com.apple.nsurlsessiond: Operation not permitted 8find: /private/var/folders/js/77b1ttqn6dlgdc3qw57s6_xh0000gn/0/com.apple.routined: Operation not permitted 9find: /private/var/folders/0n/8t0zp0d919gby3shbrd9n29r0000gp/0/com.apple.LaunchServices.dv: Operation not permitted 10find: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000y800007k/0/com.apple.nsurlsessiond: Operation not permitted 11find: /private/var/folders/7_/lk68k4bx2nqfddqqvlfzhzyr0000gq/0/com.apple.LaunchServices.dv: Operation not permitted 12/Users/ユーザー名/.oh-my-zsh/plugins/brew 13find: /dev/fd/3: Not a directory 14find: /dev/fd/4: Not a directory 15 16bash-3.2$ ls -l /usr/local/Cellar 17drwxr-xr-x 3 ユーザー名 admin 96 10 6 06:15 ruby 18 19bash-3.2$ ls -l /usr/local/lib 20drwxrwxr-x 3 ユーザー名 admin 96 9 27 22:27 dtrace 21drwxrwxr-x 16 ユーザー名 admin 512 1 23 17:57 node_modules 22drwxr-xr-x 3 ユーザー名 admin 96 7 21 2017 python2.7 23drwxr-xr-x 4 ユーザー名 admin 128 1 24 17:17 ruby

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/01/23 09:36
2018/01/23 11:14
2018/01/23 12:11
2018/01/23 16:00 編集
2018/01/24 00:49
2018/01/24 02:27
2018/01/24 09:40
2018/01/25 12:09 編集
2018/01/24 11:21
2018/01/24 12:54
2018/01/25 08:06