Help us understand the problem. What is going on with this article?

[Laravel-mix] npm run dev で sh: cross-env: command not found

More than 1 year has passed since last update.

環境

CenntOS 7.3
Laravel 5.5(5.4でも同じエラーになる)
PHP 7.1.9
npm 3.10.10
node 6.11.1

WindowsのDirをDocker環境にmountしてるので
--no-bin-links つけてます。

注)2017/8/31時点での成功例です。

現象

npm run dev
実行時に「sh: cross-env: command not found」となる。

2017/8/21の時点では
npm install cross-env --save-dev --no-bin-links
で良かったのに、8/30にはダメになってた。

手順

1) node npm install

yum
sudo yum install -y nodejs npm https://kojipkgs.fedoraproject.org//packages/http-parser/2.7.1/3.el7/x86_64/http-parser-2.7.1-3.el7.x86_64.rpm

2) project作成

composer
composer create-project laravel/laravel:5.5.* --prefer-dist mix

3) mix環境作成

■ package.json のdevDependenciesから "cross-env": "^5.0.1", を削除

shell
cd mix
vi package.json             [devDependenciesからcross-envを削除]
npm -g install cross-env cross-spawn [globalに入れる]
npm install --no-bin-links  [npm ERR! Maximum call stack size exceededとなる]
npm install --no-bin-links  [再度実行]
npm rebuild --no-bin-links  [ERRになったのでrebuild]
npm run dev                 [DONE Compiled successfullyとなる筈]

※npm install --no-bin-links 実行時にパーミッションエラーになったら
キャッシュがよくないみたいですので全部消してやり直しました。

shell
npm cache clean
rm -Rf ~/.npm
rm -Rf ./node_modules

追記:cross-spawnも必要でした。

参照
CentOS 7.3でyum install nodejsが失敗するので回避する
Compile assets with Laravel Mix Error on Laravel 5.4 and Node.js
Laravel 5.4 'cross-env' is not recognized as an internal or external command

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした