Running on windows 10, new install of node, homestead and laravel, completely new project with 'laravel new project-name'.
Laravel's running smoothly but I can't seem to get app.scss to build by using 'npm run dev' in homestead ssh gives me the following error:
cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
sh: 1: cross-env: not found
npm ERR! Linux 4.4.0-51-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "dev"
npm ERR! node v6.10.0
npm ERR! npm v3.10.10
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! @ dev:cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the @ dev script 'cross-env 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! cross-env 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.
So I added node node_modules/ to the dev script in packages.json, like so:
"dev": "node node_modules/cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
Now the command executed without any problems, however my app.css is not updated with the changes from app.scss. Here's hoping someone knows the solution to this or what I'm doing wrong?
Remove the node_modules that you put in the script and do npm install --save-dev cross-env and then try.
Hey @joshmanders, thanks for the support.
After changing the script to "dev": "node cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" and running npm install --save-dev --no-bin-links cross-env the 'npm run dev' command gives the following error:
node cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
module.js:471
throw err;
^Error: Cannot find module '/home/vagrant/Code/evotis-backoffice/cross-env'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3npm ERR! Linux 4.4.0-51-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "dev"
npm ERR! node v6.10.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ dev:node cross-env 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 cross-env 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 cross-env 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.
Adding the node_modules back still executes the command without errors, but doesn't actually build the changes in app.scss, so nothing's changed, I'm afraid.
Why did you add --no-bin-links? The command uses a bin file that is created after installing cross-env so of course it's gonna fail if the bin file can't be found.
Windows doesn't support symbolic links so I guess he really need to specify the --no-bin-links option...
I'm not entirely sure about @kentcdodds package, but it seems to be built for using cross OS' such as on Windows, so I'd expect the bin file to be useable.
If I run npm install without the --no-bin-links option, I get errors. It's was mentioned in the laravel documentation that it might be necessary.
Anyone else can confirm the same failure on Windows10?
I'll try on another Windows 10 machine when I get home.
I remember facing some problems with cross-env as well. For some reason, the laravel installation doesn't come with it by default, but for me it was as simple as just installing it manually and everything works fine. I use Windows 10 + VirtualBox + CentOS 7. The --no-bin-links is the only solution to avoid a protocol error when hitting the NTFS format.
I'm getting the exact same behaviour on a different Windows 10 machine with all included software a clean install. @deleugpn where you using the current latest version of laravel? Perhaps I'll try with an older version.
I have tried both 5.4 and 5.4@dev recently and they both gives the same problem: cross-env doesn't come as default, you install it and it just works from there on.
Well, I'm positive I have cross_env, as it's in the project's node_modules now, I still need to add node node_modules/ to the script in package.json in order for it to run without errors and even when it runs without errors my scss is not actually built. Going to give using an older version a go until a solution presents itself.
Edit: FYI using Laravel 5.3.30 gulp builds the css just fine.
Everyone - if you're getting "cross-env" not found, do npm install cross-env -D, and then make sure that you update your npm scripts in package.json to reference cross-env, rather than the full node_modules path to cross-env.
If you do pass --no-bin-links, then effectively your node_modules/.bin will be empty, hence no cross-env binary which can be run. I guess Gulp works because it's the global binary that you invoke. In other words, there's nothing that Laravel team can do about it.
Possible solutions:
Add the following to Vagrantfile (however you do that with Homestead)
config.vm.provider "virtualbox" do |v|
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"]
end
Then you either change permissions in Windows to allow regular users to create symlinks or you'll have to remember to run Vagrant as an administrator (source).
cross-env from build commands if all developers are going to use Unix machines, it is not needed then. But likely you will still run into issues with other binaries.Other option is to just
laravel new project
cd project
npm install --no-bin-links
npm install cross-env --no-bin-links
npm install node-sass --no-bin-links
Edit package.json and replace
cross-env [...] with node node_modules/cross-env/dist/bin/cross-env.js [...]
???
Profit.
the same error on ubuntu16.04 and mint18.I just copy node_modules/cross-env/dist/bin to node_modules/cross-env/bin manually,then it works.
I installed cross-env globally and have the global bin in my Windows Path.
Closing this issue since it's not laravel-core related, quoting Jeffrey's comment:
Everyone - if you're getting "cross-env" not found, do npm install cross-env -D, and then make sure that you update your npm scripts in package.json to reference cross-env, rather than the full node_modules path to cross-env.
Please refer to Mix's repository for further details on the issue: https://github.com/JeffreyWay/laravel-mix
I have a windows computer at the office and this finally worked for me.
Hope this helps someone using Windows 10 and the newest homestead vm:
laravel new project
cd project
replace package.json scripts to this:
"dev": "NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "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_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_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_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
then:
yarn add cross-env --no-bin-links
yarn upgrade --no-bin-links
yarn install --no-bin-links
Should be good to go so try:
yarn run dev
@sojohnnysaid Do you use browsersync with homestead? If so, can you monitor the view and controllers files?
firs install yarn https://yarnpkg.com/lang/en/docs/install/
Most helpful comment
Other option is to just
Edit package.json and replace
cross-env [...]withnode node_modules/cross-env/dist/bin/cross-env.js [...]