只今Laravel5.5, homesteadを使用しローカルにてvue.jsを利用してSPAを作成しております。
その中でJavaScriptやCSSを追加・変更した際に自動的にコンパイルが行われるようにするために「npm run watch」を実行すると以下のようなエラーが出てきました。
> @ watch /home/vagrant/code/school > cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js sh: 1: cross-env: not found npm ERR! file sh npm ERR! code ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn npm ERR! @ watch: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js` npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the @ watch 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! /home/vagrant/.npm/_logs/2018-04-04T03_05_00_224Z-debug.log
http://blog.asial.co.jp/1496 ←こちらのサイトを参考にし、cross-env.jsを以下のように修正
"scripts": { "dev": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", "watch": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", "watch-poll": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --watch-poll --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", "hot": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", "production": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" },
<<回答を受けて>>
npm install --save-dev cross-envを実行しました所こうエラーが出ました。
vagrant@homestead:~/code/school$ npm install --save-dev cross-env npm WARN ajv-keywords@3.1.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: assert-plus@1.0.0 (node_modules/fsevents/node_modules/dashdash/node_modules/assert-plus): npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, open '/home/vagrant/code/school/node_modules/fsevents/node_modules/dashdash/node_modules/assert-plus/package.json.4201104718' npm WARN optional SKIPPING OPTIONAL DEPENDENCY: assert-plus@1.0.0 (node_modules/fsevents/node_modules/getpass/node_modules/assert-plus): npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, open '/home/vagrant/code/school/node_modules/fsevents/node_modules/getpass/node_modules/assert-plus/package.json.670411067' npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: minimist@1.2.0 (node_modules/fsevents/node_modules/rc/node_modules/minimist): npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, open '/home/vagrant/code/school/node_modules/fsevents/node_modules/rc/node_modules/minimist/package.json.2754480345' npm WARN optional SKIPPING OPTIONAL DEPENDENCY: assert-plus@1.0.0 (node_modules/fsevents/node_modules/sshpk/node_modules/assert-plus): npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, open '/home/vagrant/code/school/node_modules/fsevents/node_modules/sshpk/node_modules/assert-plus/package.json.36804433' npm ERR! path ../cross-env/dist/bin/cross-env.js npm ERR! code EPROTO npm ERR! errno -71 npm ERR! syscall symlink npm ERR! EPROTO: protocol error, symlink '../cross-env/dist/bin/cross-env.js' -> '/home/vagrant/code/school/node_modules/.bin/cross-env' npm ERR! A complete log of this run can be found in: npm ERR! /home/vagrant/.npm/_logs/2018-04-04T06_01_57_849Z-debug.log
またfind -name "cross-env.js" -type f
で検索しても何もでてきませんでした。
<<回答を受けて②>>
単純にcross-envをinstallしてみました。
が、しかし今だにnpm run dev, npm run watch実行後はsh: 1: cross-env: not found
のままですね。。
vagrant@homestead:~/code/school$ npm install cross-env --save --no-bin-links npm WARN ajv-keywords@3.1.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: assert-plus@1.0.0 (node_modules/fsevents/node_modules/dashdash/node_modules/assert-plus): npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, open '/home/vagrant/code/school/node_modules/fsevents/node_modules/dashdash/node_modules/assert-plus/package.json.1110259093' npm WARN optional SKIPPING OPTIONAL DEPENDENCY: assert-plus@1.0.0 (node_modules/fsevents/node_modules/getpass/node_modules/assert-plus): npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, open '/home/vagrant/code/school/node_modules/fsevents/node_modules/getpass/node_modules/assert-plus/package.json.1816258176' npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: assert-plus@1.0.0 (node_modules/fsevents/node_modules/sshpk/node_modules/assert-plus): npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, open '/home/vagrant/code/school/node_modules/fsevents/node_modules/sshpk/node_modules/assert-plus/package.json.4166844666' npm WARN optional SKIPPING OPTIONAL DEPENDENCY: minimist@1.2.0 (node_modules/fsevents/node_modules/rc/node_modules/minimist): npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, open '/home/vagrant/code/school/node_modules/fsevents/node_modules/rc/node_modules/minimist/package.json.3366993945' + cross-env@5.1.4 added 1 package in 41.555s
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/04/04 06:13
2018/04/04 06:46
2018/04/04 13:29
2018/04/05 00:53
2018/04/05 00:59 編集
2018/04/05 00:58
2018/04/05 01:12
2018/04/05 01:35