実現したいこと
WSL2上のUbuntuでnpm run devコマンドを正常に実行する
発生している問題・分からないこと
ほんとに初学者で、質問も分かりにくくて申し訳ないです。前に、Laravelを使った簡易的なブログのアプリケーションをxamppで構築したのですが、それをDockerを使って動かしたいと思い、環境を構築しています。
wsl integrationの有効化は設定済みです。
今までUbuntuのターミナルで実行したコマンドは以下です。
docker run -it -v $(pwd):/opt -w /opt laravelsail/php81-composer:latest /bin/bash
composer create-project 'laravel/laravel:10.*' sail-example
cd sail-example
php artisan sail:install
exit
./vendor/bin/sail up -d
sudo chown -R ユーザー名:ユーザー名 .
./vendor/bin/sail php artisan key:generate
./vendor/bin/sail composer require laravel/ui
ここでディレクトリに対して適切な書き込み権限がないというエラーが出て、Linux ファイル システムのルート ディレクトリにファイルをコピーして作業再開しました。(それまでは、適当な位置にディレクトリを作って、/mnt/c/ディレクトリ名 のような感じで実行していました。)
./vendor/bin/sail artisan ui vue --auth
現在、Laravelのトップページが開けて、とphp my adminでデータベースを構築する準備ができている状態です。
package.jsonには以下のように書かれています。
{ "private": true, "type": "module", "scripts": { "dev": "vite", "build": "vite build" }, "devDependencies": { "@popperjs/core": "^2.11.6", "@vitejs/plugin-vue": "^4.5.0", "axios": "^1.6.4", "bootstrap": "^5.2.3", "laravel-vite-plugin": "^1.0.0", "sass": "^1.56.1", "vite": "^5.0.0", "vue": "^3.2.37" } }
エラーメッセージ
Ubuntuで、./vendor/bin/sail npm installと実行すると以下のようなエラーが出ます。
error
1root@LAPTOP-QSAVH99J:/home/kitano/sail-example# ./vendor/bin/sail npm install 2npm error code EACCES 3npm error syscall mkdir 4npm error path /var/www/html/node_modules/@popperjs 5npm error errno -13 6npm error [Error: EACCES: permission denied, mkdir '/var/www/html/node_modules/@popperjs'] { 7npm error errno: -13, 8npm error code: 'EACCES', 9npm error syscall: 'mkdir', 10npm error path: '/var/www/html/node_modules/@popperjs' 11npm error } 12npm error 13npm error The operation was rejected by your operating system. 14npm error It is likely you do not have the permissions to access this file as the current user 15npm error 16npm error If you believe this might be a permissions issue, please double-check the 17npm error permissions of the file and its containing directories, or try running 18npm error the command again as root/Administrator. 19 20npm error A complete log of this run can be found in: /home/sail/.npm/_logs/2024-04-30T06_22_51_017Z-debug-0.log 21
該当のソースコード
特になし
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
Node.jsとnpmをWSLのUbuntuに再インストールしましたが、問題は解決しませんでした。
npmのキャッシュをクリアしましたが、同じエラーが出続けています。
補足
WSL2を使用しているWindows 11の環境で発生しています。特に、esbuildのインストール中にWindowsのパスが参照されることが問題となっているようです。また、この問題はDockerコンテナ内で発生しており、Dockerのセットアップや設定が関係している可能性があります。どのようにこの問題を解決すればよいか、具体的な手順を教えていただきたいです。