Skip to content
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

'npm run dev' doesn't do anything (Windows 10) #18446

Closed
jellebean opened this issue Mar 22, 2017 · 21 comments
Closed

'npm run dev' doesn't do anything (Windows 10) #18446

jellebean opened this issue Mar 22, 2017 · 21 comments

Comments

@jellebean
Copy link

  • Laravel Version: 5.4.16
  • PHP Version: 7.1.2-3+deb.sury.org~xenial+1 (Homestead)
  • Database Driver & Version:

Description:

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?

Steps To Reproduce:

@joshmanders
Copy link
Contributor

Remove the node_modules that you put in the script and do npm install --save-dev cross-env and then try.

@jellebean
Copy link
Author

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:3

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! 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.

@joshmanders
Copy link
Contributor

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.

@fernandobandeira
Copy link
Contributor

fernandobandeira commented Mar 22, 2017

Windows doesn't support symbolic links so I guess he really need to specify the --no-bin-links option...

@joshmanders
Copy link
Contributor

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.

@jellebean
Copy link
Author

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.

@themsaid
Copy link
Member

Anyone else can confirm the same failure on Windows10?

@jellebean
Copy link
Author

I'll try on another Windows 10 machine when I get home.

@deleugpn
Copy link
Contributor

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.

@jellebean
Copy link
Author

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.

@deleugpn
Copy link
Contributor

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.

@jellebean
Copy link
Author

jellebean commented Mar 24, 2017

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.

@jellebean jellebean changed the title 'npm run dev' doesn't do anything 'npm run dev' doesn't do anything (Windows 10) Mar 24, 2017
@JeffreyWay
Copy link
Contributor

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.

@mrliptontea
Copy link

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:

  1. Install Node.js, and npm dependencies on a host machine - this will also result in a better performance with webpack, because there won't be VirtualBox overhead. That's what I do and it works well.
    You might need to adjust config if you plan to use webpack-dev-server.

  2. 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).

  3. Remove 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.

@deleugpn
Copy link
Contributor

deleugpn commented Mar 26, 2017

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.

@zedisdog
Copy link

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.

@pitchinnate
Copy link

I installed cross-env globally and have the global bin in my Windows Path.

@themsaid
Copy link
Member

themsaid commented Apr 5, 2017

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

@themsaid themsaid closed this as completed Apr 5, 2017
@sojohnnysaid
Copy link

sojohnnysaid commented Apr 11, 2017

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

@garbinmarcelo
Copy link

@sojohnnysaid Do you use browsersync with homestead? If so, can you monitor the view and controllers files?

@SamyMwamba
Copy link

firs install yarn https://yarnpkg.com/lang/en/docs/install/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests