この広告は30日以上更新がないブログに表示されております。
新規記事の投稿を行うことで、非表示にすることが可能です。
広告
posted by fanblog
2021年07月02日
npm install && npm run devでコマンドエラー|Laravel学習
のんびりさんは現在Laravelの勉強しています
渋谷で働くエンジニア福さんのLaravel入門でnpm install && npm run devコマンドを叩いたらたらエラーが出ました
そもそも、npmもはいってなく、Node.jsインストールしなきゃいけないなんて超初心者ののんびりさんにはばっかり。
とりあえず解決できたので、備忘録としてまとめます。
OS:Windows10
PHP:PHP 7.4.20
Laravel:Laravel Framework 8.48.1
MySQL:MySQL Server 8.0 (Ver 8.0.23 for Win64 on x86_64 (MySQL Community Server - GPL))
Node.js:14.17.20
npm:6.14.13
渋谷で働くエンジニア福さんのLaravel入門でnpm install && npm run devコマンドを叩いたらたらエラーが出ました
そもそも、npmもはいってなく、Node.jsインストールしなきゃいけないなんて超初心者ののんびりさんにはばっかり。
とりあえず解決できたので、備忘録としてまとめます。
開発環境
OS:Windows10
PHP:PHP 7.4.20
Laravel:Laravel Framework 8.48.1
MySQL:MySQL Server 8.0 (Ver 8.0.23 for Win64 on x86_64 (MySQL Community Server - GPL))
Node.js:14.17.20
npm:6.14.13
もくじ
- npm install && npm run devコマンドでエラー
- npm installコマンドを再度たたく
- npm run devコマンドを再度たたく
npm install && npm run devコマンドでエラー
C:\Users\NONBIRI>cd ../../MAMP/htdocs/blog
C:\MAMP\htdocs\blog> npm install && npm run dev
npm WARN deprecated popper.js@1.16.1: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
npm WARN deprecated querystring@0.2.0: The
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
added 775 packages from 447 contributors and audited 778 packages in 57.261s
83 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
> @ dev C:\MAMP\htdocs\blog
> npm run development
> @ development C:\MAMP\htdocs\blog
> mix
Additional dependencies must be installed. This will only take a moment.
Running: npm install resolve-url-loader@^4.0.0 --save-dev --legacy-peer-deps
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
Finished. Please run Mix again.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `mix`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\NONBIRI\AppData\Roaming\npm-cache\_logs\2021-07-02T04_55_39_819Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\NONBIRI\AppData\Roaming\npm-cache\_logs\2021-07-02T04_55_39_880Z-debug.log
C:\MAMP\htdocs\blog> npm install && npm run dev
npm WARN deprecated popper.js@1.16.1: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
npm WARN deprecated querystring@0.2.0: The
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
added 775 packages from 447 contributors and audited 778 packages in 57.261s
83 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
> @ dev C:\MAMP\htdocs\blog
> npm run development
> @ development C:\MAMP\htdocs\blog
> mix
Additional dependencies must be installed. This will only take a moment.
Running: npm install resolve-url-loader@^4.0.0 --save-dev --legacy-peer-deps
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
Finished. Please run Mix again.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `mix`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\NONBIRI\AppData\Roaming\npm-cache\_logs\2021-07-02T04_55_39_819Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\NONBIRI\AppData\Roaming\npm-cache\_logs\2021-07-02T04_55_39_880Z-debug.log
“Finished. Please run Mix again.”という事で、もう一度コマンドを打ってとのメッセージが…
npm installコマンドを再度たたく
C:\MAMP\htdocs\blog> npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
audited 788 packages in 7.957s
84 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
audited 788 packages in 7.957s
84 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
npm run devコマンドを再度たたく
C:\MAMP\htdocs\blog> npm run dev
> @ dev C:\MAMP\htdocs\blog
> npm run development
> @ development C:\MAMP\htdocs\blog
> mix
* Mix ????????????????????????? building (10%) 0/2 entries 2/3 dependencies 0/2 modules 2 active
...r ≫ postcss-loader ≫ resolve-url-loader ≫ sass-loader ≫ resources\sass\app.scss
DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.
Recommendation: math.div($spacer, 2)
More info and automated migrator: https://sass-lang.com/d/slash-div
?
302 │ $headings-margin-bottom: $spacer / 2 !default;
│ ^^^^^^^^^^^
?
node_modules\bootstrap\scss\_variables.scss 302:31 @import
node_modules\bootstrap\scss\bootstrap.scss 9:9 @import
resources\sass\app.scss 8:9 root stylesheet
DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.
Recommendation: math.div($input-padding-y, 2)
More info and automated migrator: https://sass-lang.com/d/slash-div
?
498 │ $input-height-inner-quarter: add($input-line-height * .25em, $input-padding-y / 2) !default;
│ ^^^^^^^^^^^^^^^^^^^^
?
node_modules\bootstrap\scss\_variables.scss 498:73 @import
node_modules\bootstrap\scss\bootstrap.scss 9:9 @import
resources\sass\app.scss 8:9 root stylesheet
DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.
Recommendation: math.div($custom-control-indicator-size, 2)
More info and automated migrator: https://sass-lang.com/d/slash-div
(−−−−途中省略ーーーー)
Laravel Mix v6.0.25
Compiled Successfully in 10492ms
┌──────────────────────────────────────────────────┬──────────┐│ File │ Size │├─────────────────────────────────────────────────┼──────────┤│ /js/app.js │ 2.92 MiB ││ css/app.css │ 178 KiB │└─────────────────────────────────────────────────┴──────────┘webpack compiled successfully
C:\MAMP\htdocs\blog>
> @ dev C:\MAMP\htdocs\blog
> npm run development
> @ development C:\MAMP\htdocs\blog
> mix
* Mix ????????????????????????? building (10%) 0/2 entries 2/3 dependencies 0/2 modules 2 active
...r ≫ postcss-loader ≫ resolve-url-loader ≫ sass-loader ≫ resources\sass\app.scss
DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.
Recommendation: math.div($spacer, 2)
More info and automated migrator: https://sass-lang.com/d/slash-div
?
302 │ $headings-margin-bottom: $spacer / 2 !default;
│ ^^^^^^^^^^^
?
node_modules\bootstrap\scss\_variables.scss 302:31 @import
node_modules\bootstrap\scss\bootstrap.scss 9:9 @import
resources\sass\app.scss 8:9 root stylesheet
DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.
Recommendation: math.div($input-padding-y, 2)
More info and automated migrator: https://sass-lang.com/d/slash-div
?
498 │ $input-height-inner-quarter: add($input-line-height * .25em, $input-padding-y / 2) !default;
│ ^^^^^^^^^^^^^^^^^^^^
?
node_modules\bootstrap\scss\_variables.scss 498:73 @import
node_modules\bootstrap\scss\bootstrap.scss 9:9 @import
resources\sass\app.scss 8:9 root stylesheet
DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.
Recommendation: math.div($custom-control-indicator-size, 2)
More info and automated migrator: https://sass-lang.com/d/slash-div
(−−−−途中省略ーーーー)
Laravel Mix v6.0.25
Compiled Successfully in 10492ms
┌──────────────────────────────────────────────────┬──────────┐│ File │ Size │├─────────────────────────────────────────────────┼──────────┤│ /js/app.js │ 2.92 MiB ││ css/app.css │ 178 KiB │└─────────────────────────────────────────────────┴──────────┘webpack compiled successfully
C:\MAMP\htdocs\blog>
npm install && npm run devコマンドでエラー後は再度、“npm install”と“npm run dev”で分けてコマンドを打ってみた所、無事コンプリートしました。
npm install && npm run devで一緒に打ってもよかったのか…ちょっと慎重に分けてコマンドを打ったのんびりさんなのでした
出典:渋谷で働くエンジニア福の「実践で学ぶプログラミング入門」
( https://www.youtube.com/channel/UCqzJi2o7bAPtRD3tTFvi7zA)
Target class [△△△△Controller] does not exist.のエラー|Laravel学習
のんびりさんは現在Laravelの勉強しています
渋谷で働くエンジニア福さんのLaravel入門で一覧画面を表示しようとしたらエラーが出ました
Laravelのバージョンの違うので、自分のバージョンにあった記述に修正。
備忘録としてまとめます。
OS:Windows10
PHP:PHP 7.4.20
Laravel:Laravel Framework 8.48.1
MySQL:MySQL Server 8.0 (Ver 8.0.23 for Win64 on x86_64 (MySQL Community Server - GPL))
Node.js:14.17.20
npm:6.14.13
渋谷で働くエンジニア福さんのLaravel入門で一覧画面を表示しようとしたらエラーが出ました
Laravelのバージョンの違うので、自分のバージョンにあった記述に修正。
備忘録としてまとめます。
開発環境
OS:Windows10
PHP:PHP 7.4.20
Laravel:Laravel Framework 8.48.1
MySQL:MySQL Server 8.0 (Ver 8.0.23 for Win64 on x86_64 (MySQL Community Server - GPL))
Node.js:14.17.20
npm:6.14.13
もくじ
- BlogController.phpの記述
- web.phpの記述
- RouteServiceProvider.phpの修正
BlogController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class BlogController extends Controller
{
/*
* ブログ一覧を表示する
*
* @return view
*/
public function showList()
{
return view('blog.list');
}
}
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class BlogController extends Controller
{
/*
* ブログ一覧を表示する
*
* @return view
*/
public function showList()
{
return view('blog.list');
}
}
web.php
<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
// ブログ一覧画面を表示
Route::get('/', 'BlogController@showList')->name('blogs');
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
// ブログ一覧画面を表示
Route::get('/', 'BlogController@showList')->name('blogs');
RouteServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
* This is used by Laravel authentication to redirect users after login.
*
* @var string
*/
public const HOME = '/home';
/**
* The controller namespace for the application.
*
* When present, controller route declarations will automatically be prefixed with this namespace.
*
* @var string|null
*/
// protected $namespace = 'App\\Http\\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
protected $namespace = 'App\Http\Controllers'; //追加
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
});
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
}
}
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
* This is used by Laravel authentication to redirect users after login.
*
* @var string
*/
public const HOME = '/home';
/**
* The controller namespace for the application.
*
* When present, controller route declarations will automatically be prefixed with this namespace.
*
* @var string|null
*/
// protected $namespace = 'App\\Http\\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
protected $namespace = 'App\Http\Controllers'; //追加
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
});
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
}
}
protected $namespace = 'App\Http\Controllers';を36行目に追記
出典:渋谷で働くエンジニア福の「実践で学ぶプログラミング入門」
( https://www.youtube.com/channel/UCqzJi2o7bAPtRD3tTFvi7zA)
php artisan db:seed でエラー|Laravel学習
のんびりさんは現在Laravelの勉強しています
渋谷で働くエンジニア福さんのLaravel入門でつまづいたので備忘録まとめます。
YouTube動画ではおそらくMacOSでLaravelのバージョンが5.8ですが、環境等が違っていました。
OS:Windows10
PHP:PHP 7.4.20
Laravel:Laravel Framework 8.48.1
MySQL:MySQL Server 8.0 (Ver 8.0.23 for Win64 on x86_64 (MySQL Community Server - GPL))
Node.js:14.17.20
npm:6.14.13
渋谷で働くエンジニア福さんのLaravel入門でつまづいたので備忘録まとめます。
YouTube動画ではおそらくMacOSでLaravelのバージョンが5.8ですが、環境等が違っていました。
開発環境
OS:Windows10
PHP:PHP 7.4.20
Laravel:Laravel Framework 8.48.1
MySQL:MySQL Server 8.0 (Ver 8.0.23 for Win64 on x86_64 (MySQL Community Server - GPL))
Node.js:14.17.20
npm:6.14.13
もくじ
- Models/Blog.phpの記述
- BlogsTableSeeder.phpの修正
- BlogFactory.phpの修正
- DatabaseSeeder.phpの修正
Models/Blog.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Blog extends Model
{
use HasFactory;
// テーブル名
protected $table = 'blogs';
// 可変項目
protected $fillable =
[
'title',
'content'
];
}
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Blog extends Model
{
use HasFactory;
// テーブル名
protected $table = 'blogs';
// 可変項目
protected $fillable =
[
'title',
'content'
];
}
BlogsTableSeeder.php
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\Blog;
class BlogsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(App\Models\Blog::class)->create();
}
}
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\Blog;
class BlogsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(App\Models\Blog::class)->create();
}
}
動画では“factory(Blog::class, 15)->create();”となっていたが、修正。
BlogFactory.php
<?php
namespace Database\Factories;
use App\Models\Blog;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class BlogFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Blog::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'title' => $this->faker->word,
'content' => $this->faker->realText
];
}
}
namespace Database\Factories;
use App\Models\Blog;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class BlogFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Blog::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'title' => $this->faker->word,
'content' => $this->faker->realText
];
}
}
こちらも“'title' => $Faker->word,”と“'content' => $Faker->realText,”と書かれていたが、$thisをつける書き方に修正
DatabaseSeeder.php
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
\App\Models\Blog::factory(15)->create();
}
}
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
\App\Models\Blog::factory(15)->create();
}
}
こちらも“$this->call(BlogsTableSeeder::class);”と書かれていたが、修正
出典:渋谷で働くエンジニア福の「実践で学ぶプログラミング入門」
( https://www.youtube.com/channel/UCqzJi2o7bAPtRD3tTFvi7zA)