New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module cross-env #478

Closed
phuclh opened this Issue Feb 26, 2017 · 56 comments

Comments

Projects
None yet
@phuclh

phuclh commented Feb 26, 2017

  • Laravel Mix Version: 0.8.7
  • Node Version (node -v): 7.6.0
  • NPM Version (npm -v): 4.3.0
  • OS: MacOS

Description:

I am using Spark (latest version) but when I compiled css and js by using npm run dev then I got an error:

Cannot find module '/PATH/node_modules/cross-env/bin/cross-env.js'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:422:7)
    at startup (bootstrap_node.js:143:9)
    at bootstrap_node.js:537:3

npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v7.6.0
npm ERR! npm  v4.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `node node_modules/cross-env/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`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ dev script 'node node_modules/cross-env/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'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node node_modules/cross-env/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
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs 
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls 
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/.npm/_logs/2017-02-26T08_26_31_924Z-debug.log

I tried to update npm, node, laravel-mix and remove all modules in node_modules and re-install but I still got that error.

@JeffreyWay

This comment has been minimized.

Show comment
Hide comment
@JeffreyWay

JeffreyWay Feb 26, 2017

Owner

Can you check your installed version of Mix again? 0.8.7 doesn't exist.

Owner

JeffreyWay commented Feb 26, 2017

Can you check your installed version of Mix again? 0.8.7 doesn't exist.

@iHazzam

This comment has been minimized.

Show comment
Hide comment
@iHazzam

iHazzam Feb 26, 2017

If you're using homestead, you get this error if you run the command in the VM.

#447

Try the scripts in the link rather than the ones you are currently using in your config

iHazzam commented Feb 26, 2017

If you're using homestead, you get this error if you run the command in the VM.

#447

Try the scripts in the link rather than the ones you are currently using in your config

@dwoodard

This comment has been minimized.

Show comment
Hide comment
@dwoodard

dwoodard Mar 4, 2017

cross-env must have updated its paths, it has "cross-env/dist/bin" not "cross-env/bin/"

in package.json
(EDIT)

    "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"

dwoodard commented Mar 4, 2017

cross-env must have updated its paths, it has "cross-env/dist/bin" not "cross-env/bin/"

in package.json
(EDIT)

    "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"
@Jam0r85

This comment has been minimized.

Show comment
Hide comment
@Jam0r85

Jam0r85 Mar 5, 2017

@dwoodard +1 thank you! This worked for me. Been trying top figure this out all day!

Jam0r85 commented Mar 5, 2017

@dwoodard +1 thank you! This worked for me. Been trying top figure this out all day!

@marcusrall

This comment has been minimized.

Show comment
Hide comment
@marcusrall

marcusrall commented Mar 5, 2017

@dwoodard nice, thanks

@devcronix

This comment has been minimized.

Show comment
Hide comment
@devcronix

devcronix Mar 6, 2017

@dwoodard, works, thank you!

devcronix commented Mar 6, 2017

@dwoodard, works, thank you!

@jivemonkey2000

This comment has been minimized.

Show comment
Hide comment
@jivemonkey2000

jivemonkey2000 Mar 6, 2017

First result on Google, and worked first time. Thank you @dwoodard.

jivemonkey2000 commented Mar 6, 2017

First result on Google, and worked first time. Thank you @dwoodard.

@ikiugu

This comment has been minimized.

Show comment
Hide comment
@ikiugu

ikiugu Mar 6, 2017

@dwoodard Thanks alot for this!!!

ikiugu commented Mar 6, 2017

@dwoodard Thanks alot for this!!!

@garethdaine

This comment has been minimized.

Show comment
Hide comment
@garethdaine

garethdaine Mar 6, 2017

You'll need to change the references to this path for all scripts, including:

  • dev
  • watch
  • hot
  • production

garethdaine commented Mar 6, 2017

You'll need to change the references to this path for all scripts, including:

  • dev
  • watch
  • hot
  • production
@michaeljoshua55555

This comment has been minimized.

Show comment
Hide comment

michaeljoshua55555 commented Mar 7, 2017

@dwoodard Thank a lot

dev-seahouse added a commit to nus-mtp/bill-organizer that referenced this issue Mar 7, 2017

puredazzle added a commit to wordplate/wordplate that referenced this issue Mar 8, 2017

Cross-env new paths
Please see this thread: JeffreyWay/laravel-mix#478
@mostafa6765

This comment has been minimized.

Show comment
Hide comment
@mostafa6765

mostafa6765 Mar 8, 2017

@phuclh

package.json paste this

{
  "private": true,
  "scripts": {
    "dev": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "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",
    "watch-poll": "cross-env 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": "cross-env 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": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "axios": "^0.15.3",
    "bootstrap-sass": "^3.3.7",
    "cross-env": "^3.2.3",
    "jquery": "^3.1.1",
    "laravel-mix": "^0.8.1",
    "lodash": "^4.17.4",
    "vue": "^2.1.10"
  }
}
  • npm install --save-dev cross-env
  • npm install

Now
npm run dev
npm run watch

mostafa6765 commented Mar 8, 2017

@phuclh

package.json paste this

{
  "private": true,
  "scripts": {
    "dev": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "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",
    "watch-poll": "cross-env 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": "cross-env 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": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "axios": "^0.15.3",
    "bootstrap-sass": "^3.3.7",
    "cross-env": "^3.2.3",
    "jquery": "^3.1.1",
    "laravel-mix": "^0.8.1",
    "lodash": "^4.17.4",
    "vue": "^2.1.10"
  }
}
  • npm install --save-dev cross-env
  • npm install

Now
npm run dev
npm run watch

@wakaranja

This comment has been minimized.

Show comment
Hide comment
@wakaranja

wakaranja Mar 8, 2017

Thank you. Had split some hairs because of this.

wakaranja commented Mar 8, 2017

Thank you. Had split some hairs because of this.

@amitbk

This comment has been minimized.

Show comment
Hide comment
@amitbk

amitbk Mar 8, 2017

Replacing "cross-env/bin/" with "cross-env/dist/bin" in package.json solved my issue...

Now its working fine.
Thanks @dwoodard

@JeffreyWay can you please update package.json with laravel default installation?

amitbk commented Mar 8, 2017

Replacing "cross-env/bin/" with "cross-env/dist/bin" in package.json solved my issue...

Now its working fine.
Thanks @dwoodard

@JeffreyWay can you please update package.json with laravel default installation?

bkuhl added a commit to realpage/laravel-starter that referenced this issue Mar 9, 2017

bkuhl added a commit to realpage/laravel-starter that referenced this issue Mar 9, 2017

Running cron container as root (#68)
* Running cron container as root

* Updated failing laravel-mix 

See JeffreyWay/laravel-mix#478 (comment)

wiertar added a commit to KenAer/ISYS489 that referenced this issue Mar 11, 2017

@bellalMohamed

This comment has been minimized.

Show comment
Hide comment
@bellalMohamed

bellalMohamed commented Mar 11, 2017

Thanks @dwoodard 😄

fox000 referenced this issue in laravel/laravel Mar 13, 2017

@driesvints

This comment has been minimized.

Show comment
Hide comment
@driesvints

driesvints commented Mar 13, 2017

@amitbk already been done: laravel/laravel#4167

@Daniel-Griffiths

This comment has been minimized.

Show comment
Hide comment

Daniel-Griffiths commented Mar 14, 2017

Thanks @dwoodard

@kjunggithub

This comment has been minimized.

Show comment
Hide comment
@kjunggithub

kjunggithub Mar 16, 2017

Thanks for the detailed information @mostafa6765!

kjunggithub commented Mar 16, 2017

Thanks for the detailed information @mostafa6765!

@silviolleite

This comment has been minimized.

Show comment
Hide comment
@silviolleite

silviolleite Mar 16, 2017

Thanks @phuclh it works perfectly :)

silviolleite commented Mar 16, 2017

Thanks @phuclh it works perfectly :)

@cristianmeza

This comment has been minimized.

Show comment
Hide comment
@cristianmeza

cristianmeza Mar 16, 2017

Many thanks @dwoodard, after hours of fighting in Windows, finally I have Laravel Mix working. Greetings from Chile.

cristianmeza commented Mar 16, 2017

Many thanks @dwoodard, after hours of fighting in Windows, finally I have Laravel Mix working. Greetings from Chile.

@wagelvis

This comment has been minimized.

Show comment
Hide comment
@wagelvis

wagelvis Mar 17, 2017

@dwoodard cool, thanks !!

wagelvis commented Mar 17, 2017

@dwoodard cool, thanks !!

@zcmyworld

This comment has been minimized.

Show comment
Hide comment
@zcmyworld

zcmyworld Mar 20, 2017

This worked for me.Thanks!

zcmyworld commented Mar 20, 2017

This worked for me.Thanks!

@estebangallego

This comment has been minimized.

Show comment
Hide comment

estebangallego commented Apr 5, 2017

@dwoodard Thanks!

@bart

This comment has been minimized.

Show comment
Hide comment
@bart

bart Apr 19, 2017

We had the same issue here but changing the package.json file is not a good option when you work in a big team with different dev environments. My solution here is a simple npm install -g cross-env. That should do the trick.

bart commented Apr 19, 2017

We had the same issue here but changing the package.json file is not a good option when you work in a big team with different dev environments. My solution here is a simple npm install -g cross-env. That should do the trick.

@realtebo

This comment has been minimized.

Show comment
Hide comment
@realtebo

realtebo Apr 21, 2017

Actually, I fixed with this sequence.
After that, I'm able to run npm run dev inside vagranth ssh connection

sudo rm node_modules/ -rf

# this avoid problem with `cross-env not found`

sudo npm install cross-env -g

# Execute two times to resolve the problem with ` Maximum call stack size exceeded` 
# while finalizing 
# Also note: I'm using --no-bin-links because I've a Windows 7 host

npm install --no-bin-links || npm install --no-bin-links

# this avoid problem with `Module build failed: ModuleBuildError: Module build failed:
# Error: ENOENT: no such file or directory, scandir 
#'/home/vagrant/Code/<your project name>/node_modules/node-sass/vendor' `

npm rebuild node-sass --no-bin-links



I do not alter package.json file

OPTIONAL: If you want to really clear your vagrant box do this BEFORE starting

sudo npm ls -gp --depth=0 | awk -F/ '/node_modules/ && !/\/npm$/ {print $NF}' | xargs sudo npm -g rm

Then go on removing local node_modules folder from your code folder

realtebo commented Apr 21, 2017

Actually, I fixed with this sequence.
After that, I'm able to run npm run dev inside vagranth ssh connection

sudo rm node_modules/ -rf

# this avoid problem with `cross-env not found`

sudo npm install cross-env -g

# Execute two times to resolve the problem with ` Maximum call stack size exceeded` 
# while finalizing 
# Also note: I'm using --no-bin-links because I've a Windows 7 host

npm install --no-bin-links || npm install --no-bin-links

# this avoid problem with `Module build failed: ModuleBuildError: Module build failed:
# Error: ENOENT: no such file or directory, scandir 
#'/home/vagrant/Code/<your project name>/node_modules/node-sass/vendor' `

npm rebuild node-sass --no-bin-links



I do not alter package.json file

OPTIONAL: If you want to really clear your vagrant box do this BEFORE starting

sudo npm ls -gp --depth=0 | awk -F/ '/node_modules/ && !/\/npm$/ {print $NF}' | xargs sudo npm -g rm

Then go on removing local node_modules folder from your code folder

rosswintle added a commit to rosswintle/today-i that referenced this issue May 13, 2017

@patlecat

This comment has been minimized.

Show comment
Hide comment
@patlecat

patlecat Jul 26, 2017

It's July 2017, I did a fresh installation of Homestead (on Windows 10) and Laravel 5.4 and still got this cross-env error during npm install !! But now the mix file looks different with the paths so the above tips won't work anymore.
Even after installing the cross-env pckg manually to -g I get errors with every "npm install..." or "npm run dev" command i execute inside of Homestead!

Also "npm run dev" produces the "cross-env not found" error (plus many more following that)!

Why is this still a problem after such a long time at this very basic and important functionality?

Tell the author that this fails on your system: npm ERR! cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

patlecat commented Jul 26, 2017

It's July 2017, I did a fresh installation of Homestead (on Windows 10) and Laravel 5.4 and still got this cross-env error during npm install !! But now the mix file looks different with the paths so the above tips won't work anymore.
Even after installing the cross-env pckg manually to -g I get errors with every "npm install..." or "npm run dev" command i execute inside of Homestead!

Also "npm run dev" produces the "cross-env not found" error (plus many more following that)!

Why is this still a problem after such a long time at this very basic and important functionality?

Tell the author that this fails on your system: npm ERR! cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

@ruchern

This comment has been minimized.

Show comment
Hide comment
@ruchern

ruchern Jul 26, 2017

Contributor

@patlecat Because cross-env is now removed from Laravel-Mix by default. If you are a Windows user, then you will have to install cross-env manually.

Besides, you are using Homestead and Linux should not be failing without cross-env installed.

Just delete your node_modules folder and package-lock.json file and re-run npm install. I guess you are on npm v5 and there are issues with npm deleting packages.

Contributor

ruchern commented Jul 26, 2017

@patlecat Because cross-env is now removed from Laravel-Mix by default. If you are a Windows user, then you will have to install cross-env manually.

Besides, you are using Homestead and Linux should not be failing without cross-env installed.

Just delete your node_modules folder and package-lock.json file and re-run npm install. I guess you are on npm v5 and there are issues with npm deleting packages.

@laracasts

This comment has been minimized.

Show comment
Hide comment
@laracasts

laracasts Jul 26, 2017

Collaborator
Collaborator

laracasts commented Jul 26, 2017

@patlecat

This comment has been minimized.

Show comment
Hide comment
@patlecat

patlecat Jul 31, 2017

@laracasts Yes Jeffrey I saw that it is included but somehow was not installed until I did it manually :(

@ruchern And no by using Homestead I'm not a Windows user when it comes to Laravel installation, this is on the Linux VM and uses Linux components, commands, libs and paths. I checked (since I use all the latest components with a fresh Homestead install, it's using nodejs 6.11.x LTS which has npm 3.10.x, I leave it as is, because before I had very bad experience with updating node + npm it broke everything and I had to go back to the original version of Homestead again.

patlecat commented Jul 31, 2017

@laracasts Yes Jeffrey I saw that it is included but somehow was not installed until I did it manually :(

@ruchern And no by using Homestead I'm not a Windows user when it comes to Laravel installation, this is on the Linux VM and uses Linux components, commands, libs and paths. I checked (since I use all the latest components with a fresh Homestead install, it's using nodejs 6.11.x LTS which has npm 3.10.x, I leave it as is, because before I had very bad experience with updating node + npm it broke everything and I had to go back to the original version of Homestead again.

@devcircus

This comment has been minimized.

Show comment
Hide comment
@devcircus

devcircus Jul 31, 2017

Contributor

Frontend should be handled by your local machine. You can make it work on the vm but every recommendation I've ever read was to run your backend on vm and frontend locally. I've been doing it for years with homestead and never had an issue.

Maybe it's improved over the years and recommendations have changed though...

Contributor

devcircus commented Jul 31, 2017

Frontend should be handled by your local machine. You can make it work on the vm but every recommendation I've ever read was to run your backend on vm and frontend locally. I've been doing it for years with homestead and never had an issue.

Maybe it's improved over the years and recommendations have changed though...

@ruchern

This comment has been minimized.

Show comment
Hide comment
@ruchern

ruchern Aug 1, 2017

Contributor

@patlecat I know by using Homestead you are creating a Linux environment. I wrote that just in case you accidentally ran the command on Windows CMD instead.

npm v3 could be a little outdated. You might want to try the latest version of v4.

Contributor

ruchern commented Aug 1, 2017

@patlecat I know by using Homestead you are creating a Linux environment. I wrote that just in case you accidentally ran the command on Windows CMD instead.

npm v3 could be a little outdated. You might want to try the latest version of v4.

@kwebble

This comment has been minimized.

Show comment
Hide comment
@kwebble

kwebble Aug 1, 2017

@ruchern thanks for the info.

Because cross-env is now removed from Laravel-Mix by default. If you are a Windows user, then you will have to install cross-env manually.

For me this means an application that previously build successfully suddenly failed. I hope this will be fixed, manually adding the package isn't a great solution.

kwebble commented Aug 1, 2017

@ruchern thanks for the info.

Because cross-env is now removed from Laravel-Mix by default. If you are a Windows user, then you will have to install cross-env manually.

For me this means an application that previously build successfully suddenly failed. I hope this will be fixed, manually adding the package isn't a great solution.

@JeffreyWay

This comment has been minimized.

Show comment
Hide comment
@JeffreyWay

JeffreyWay Aug 1, 2017

Owner

For me this means an application that previously build successfully suddenly failed. I hope this will be fixed, manually adding the package isn't a great solution.

We removed the dependency with the 1.0 release. It was the right time to remove that dependency. It takes five seconds to do npm i cross-env.

Owner

JeffreyWay commented Aug 1, 2017

For me this means an application that previously build successfully suddenly failed. I hope this will be fixed, manually adding the package isn't a great solution.

We removed the dependency with the 1.0 release. It was the right time to remove that dependency. It takes five seconds to do npm i cross-env.

@patlecat

This comment has been minimized.

Show comment
Hide comment
@patlecat

patlecat Aug 2, 2017

@JeffreyWay I have no problem following installation instructions, if all that is documented there. Things change, I accept and welcome that, but I'm no psychic I can't guess what changed.

@ruchern Okay so you recommend compiling the website in the VM (on linux) right? I would be totally confused if that was not the intention after all. And you recommend staying on nodejs 6.11.x but updating only npm and to the latest version 4.x?

patlecat commented Aug 2, 2017

@JeffreyWay I have no problem following installation instructions, if all that is documented there. Things change, I accept and welcome that, but I'm no psychic I can't guess what changed.

@ruchern Okay so you recommend compiling the website in the VM (on linux) right? I would be totally confused if that was not the intention after all. And you recommend staying on nodejs 6.11.x but updating only npm and to the latest version 4.x?

@ruchern

This comment has been minimized.

Show comment
Hide comment
@ruchern

ruchern Aug 2, 2017

Contributor

@patlecat Yes, you should be and I assume you did, run the scripts in the Homestead environment.

As for the npm version, the latest now is v5.3.0, but it is plagued with a lot of problems. v4 is very stable so to speak. I am not sure if v4 is outdated that it won't work anymore.

Contributor

ruchern commented Aug 2, 2017

@patlecat Yes, you should be and I assume you did, run the scripts in the Homestead environment.

As for the npm version, the latest now is v5.3.0, but it is plagued with a lot of problems. v4 is very stable so to speak. I am not sure if v4 is outdated that it won't work anymore.

@georaldc

This comment has been minimized.

Show comment
Hide comment
@georaldc

georaldc Aug 4, 2017

Frontend should be handled by your local machine. You can make it work on the vm but every recommendation I've ever read was to run your backend on vm and frontend locally. I've been doing it for years with homestead and never had an issue.

@devcircus Doesn't that become an issue if say, the project uses yarn and depends on its generated lock file? If the lock file was built under a unix environment, won't you run into issues if you install dependencies using it on your local machine if it runs on something else like Windows?

georaldc commented Aug 4, 2017

Frontend should be handled by your local machine. You can make it work on the vm but every recommendation I've ever read was to run your backend on vm and frontend locally. I've been doing it for years with homestead and never had an issue.

@devcircus Doesn't that become an issue if say, the project uses yarn and depends on its generated lock file? If the lock file was built under a unix environment, won't you run into issues if you install dependencies using it on your local machine if it runs on something else like Windows?

@devcircus

This comment has been minimized.

Show comment
Hide comment
@devcircus

devcircus Aug 4, 2017

Contributor

I've done some research in the last few days and it does seem that thoughts on this have changed in recent years. When I first started with homestead years ago, there were so many issues with npm on vagrant that everyone recommended running it on the host. I've stuck with that and never had any problems. I even use yarn on the host machine(windows). However it seems I'm behind on the current trend and although it may be a little slower, npm and yarn should work just fine on the vm.

Contributor

devcircus commented Aug 4, 2017

I've done some research in the last few days and it does seem that thoughts on this have changed in recent years. When I first started with homestead years ago, there were so many issues with npm on vagrant that everyone recommended running it on the host. I've stuck with that and never had any problems. I even use yarn on the host machine(windows). However it seems I'm behind on the current trend and although it may be a little slower, npm and yarn should work just fine on the vm.

@kwebble

This comment has been minimized.

Show comment
Hide comment
@kwebble

kwebble Aug 4, 2017

@JeffreyWay it takes a short time to install, but much more time to investigate why a script that comes with the framework ends in error.

The way to describe that a Node application needs additional code to run is by including it in package.json, why not use that mechanism?

(Added to my list of Laravel tips & pitfalls)

kwebble commented Aug 4, 2017

@JeffreyWay it takes a short time to install, but much more time to investigate why a script that comes with the framework ends in error.

The way to describe that a Node application needs additional code to run is by including it in package.json, why not use that mechanism?

(Added to my list of Laravel tips & pitfalls)

@realtebo

This comment has been minimized.

Show comment
Hide comment
@realtebo

realtebo Aug 7, 2017

@JeffreyWay

It was the right time to remove that dependency

Why? If it IS NEEDED it IS a dependency...

I'm sure I've lost something ....

realtebo commented Aug 7, 2017

@JeffreyWay

It was the right time to remove that dependency

Why? If it IS NEEDED it IS a dependency...

I'm sure I've lost something ....

@JeffreyWay

This comment has been minimized.

Show comment
Hide comment
@JeffreyWay

JeffreyWay Aug 7, 2017

Owner

@realtebo It's not required. I don't think people understand that the only use for cross-env is to allow for cross-platform npm scripts. If you're a Mac user, you don't need it. If you're a Windows users, either pull it in, or tweak the npm script to fit your platform. Mix, itself, does not depend upon cross-env.

Owner

JeffreyWay commented Aug 7, 2017

@realtebo It's not required. I don't think people understand that the only use for cross-env is to allow for cross-platform npm scripts. If you're a Mac user, you don't need it. If you're a Windows users, either pull it in, or tweak the npm script to fit your platform. Mix, itself, does not depend upon cross-env.

@ruchern

This comment has been minimized.

Show comment
Hide comment
@ruchern

ruchern Aug 7, 2017

Contributor

In addition to @JeffreyWay, Linux also does not need cross-env.

Contributor

ruchern commented Aug 7, 2017

In addition to @JeffreyWay, Linux also does not need cross-env.

@devcircus

This comment has been minimized.

Show comment
Hide comment
@devcircus

devcircus Aug 7, 2017

Contributor

I use windows without cross-env. I simply adjusted my script in package.json as below:

"development": "set NODE_ENV=development&& webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "set NODE_ENV=development&& webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
//
Contributor

devcircus commented Aug 7, 2017

I use windows without cross-env. I simply adjusted my script in package.json as below:

"development": "set NODE_ENV=development&& webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "set NODE_ENV=development&& webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
//
@patlecat

This comment has been minimized.

Show comment
Hide comment
@patlecat

patlecat Aug 7, 2017

Is Laravel-Mix actually known to work consistently and flawlessly on any other platform than Mac OSX? I wonder, do you guys even test it as thoroughly under Linux like Ubuntu and Homestead?

patlecat commented Aug 7, 2017

Is Laravel-Mix actually known to work consistently and flawlessly on any other platform than Mac OSX? I wonder, do you guys even test it as thoroughly under Linux like Ubuntu and Homestead?

@ruchern

This comment has been minimized.

Show comment
Hide comment
@ruchern

ruchern Aug 7, 2017

Contributor

@patlecat Yes. I am running macOS 10.12 on my machine and Linux (Ubuntu) on my production server (NOT Homestead) and it worked right out from the box.

Contributor

ruchern commented Aug 7, 2017

@patlecat Yes. I am running macOS 10.12 on my machine and Linux (Ubuntu) on my production server (NOT Homestead) and it worked right out from the box.

@patlecat

This comment has been minimized.

Show comment
Hide comment
@patlecat

patlecat Aug 7, 2017

@ruchern Okay so you tested it personally like a dev on 2 OS? And do you know of any more formal testing environments and methods?

@JeffreyWay Maybe you can also comment on this? It would be an invaluable information.

patlecat commented Aug 7, 2017

@ruchern Okay so you tested it personally like a dev on 2 OS? And do you know of any more formal testing environments and methods?

@JeffreyWay Maybe you can also comment on this? It would be an invaluable information.

@devcircus

This comment has been minimized.

Show comment
Hide comment
@devcircus

devcircus Aug 7, 2017

Contributor

Mix has a full test suite. Just fork, clone, and run the tests on the OS of your choosing.

Contributor

devcircus commented Aug 7, 2017

Mix has a full test suite. Just fork, clone, and run the tests on the OS of your choosing.

@ruchern

This comment has been minimized.

Show comment
Hide comment
@ruchern

ruchern Aug 8, 2017

Contributor

@patlecat Yes, I did. I think you should use a CI and push your code to Github repo and see if the CI builds your stuff properly.

Contributor

ruchern commented Aug 8, 2017

@patlecat Yes, I did. I think you should use a CI and push your code to Github repo and see if the CI builds your stuff properly.

@patlecat

This comment has been minimized.

Show comment
Hide comment
@patlecat

patlecat Aug 9, 2017

@ruchern To push what exactly into the CI? My fresh installation out of the box of Laravel and Mix that produced errors? Or what do you suggest?

patlecat commented Aug 9, 2017

@ruchern To push what exactly into the CI? My fresh installation out of the box of Laravel and Mix that produced errors? Or what do you suggest?

@jmanzo

This comment has been minimized.

Show comment
Hide comment
@jmanzo

jmanzo Aug 10, 2017

I just install yarn command globally: https://yarnpkg.com/en/docs/install

This help me a lot to clear my panoram...

jmanzo commented Aug 10, 2017

I just install yarn command globally: https://yarnpkg.com/en/docs/install

This help me a lot to clear my panoram...

@brian-lamb-software-engineer

This comment has been minimized.

Show comment
Hide comment
@brian-lamb-software-engineer

brian-lamb-software-engineer Aug 24, 2017

@phuclh thats what i had, and had to switch to what @dwoodard initially recommended. This is working fine on my other package, today i used powershell to run npm, as opposed to vbox linux, and ran into this in the new app. not sure, if they just changed something then i should be seeing this on all apps after running npm install.

@phuclh thats what i had, and had to switch to what @dwoodard initially recommended. This is working fine on my other package, today i used powershell to run npm, as opposed to vbox linux, and ran into this in the new app. not sure, if they just changed something then i should be seeing this on all apps after running npm install.

@adanwo

This comment has been minimized.

Show comment
Hide comment
@adanwo

adanwo Sep 19, 2017

From Windows:
Right clic over folder.
Git bash
npm run dev

adanwo commented Sep 19, 2017

From Windows:
Right clic over folder.
Git bash
npm run dev

@OnlyCRed

This comment has been minimized.

Show comment
Hide comment
@OnlyCRed

OnlyCRed Oct 7, 2017

HOMESTEAD v6.2.2 VAGRANT BOX WINDOWS 10, RUNNING GITBASH AS AN ADMINISTRATOR
LARAVEL 5.4 FROM SCRATCH: Episode 14 Laravel Mix and the Front-end
cd /home/vagrant/Code/Laravel

sudo chown -R $USER:$(id -gn $USER) /home/vagrant/.config

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

sudo apt-get install -y nodejs

node -v

npm -v

npm install -g yarn

sudo npm install --save-dev cross-env

sudo npm install --no-bin-links

sudo yarn install

sudo npm dev

OnlyCRed commented Oct 7, 2017

HOMESTEAD v6.2.2 VAGRANT BOX WINDOWS 10, RUNNING GITBASH AS AN ADMINISTRATOR
LARAVEL 5.4 FROM SCRATCH: Episode 14 Laravel Mix and the Front-end
cd /home/vagrant/Code/Laravel

sudo chown -R $USER:$(id -gn $USER) /home/vagrant/.config

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

sudo apt-get install -y nodejs

node -v

npm -v

npm install -g yarn

sudo npm install --save-dev cross-env

sudo npm install --no-bin-links

sudo yarn install

sudo npm dev

@petiibhuzah

This comment has been minimized.

Show comment
Hide comment
@petiibhuzah

petiibhuzah Oct 10, 2017

@phuclh try to check the installation path of node.js in Environment variables

petiibhuzah commented Oct 10, 2017

@phuclh try to check the installation path of node.js in Environment variables

@977developer

This comment has been minimized.

Show comment
Hide comment
@977developer

977developer Dec 28, 2017

In package.json, npm run dev is directly trying to run 'cross-env + command'

If you install cross-env globally, it will fix the problem.

sudo npm i -g cross-env

It is that simple.

977developer commented Dec 28, 2017

In package.json, npm run dev is directly trying to run 'cross-env + command'

If you install cross-env globally, it will fix the problem.

sudo npm i -g cross-env

It is that simple.

@ruchern

This comment has been minimized.

Show comment
Hide comment
@ruchern

ruchern Dec 29, 2017

Contributor

@977developer If you are on macOS or Linux, just remove cross-env from the scripts in package.json

Contributor

ruchern commented Dec 29, 2017

@977developer If you are on macOS or Linux, just remove cross-env from the scripts in package.json

@progietheus

This comment has been minimized.

Show comment
Hide comment
@progietheus

progietheus Jan 9, 2018

@977developer Thank you, this is the answer!

progietheus commented Jan 9, 2018

@977developer Thank you, this is the answer!

@flik

This comment has been minimized.

Show comment
Hide comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment