Is there a way to start node.js's lite-server from grunt?
I have grunt in watch mode and to use both at the same time I need to open two command prompt (windows). I'd prefer to start both with one grunt command - if possible.
The plugin grunt-exec does the trick with the command npm run lite (depending on package.json configuration).
Related
I've installed both the grunt-cli and grunt globally using the -g option.
However when I try and run grunt I get this error:
grunt --gruntfile /Users/a/root/config/Gruntfile.js
grunt-cli: The grunt command line interface. (v0.1.13)
Fatal error: Unable to find local grunt.
If you're seeing this message, either a Gruntfile wasn't found or grunt
hasn't been installed locally to your project. For more information about
installing and configuring grunt, please see the Getting Started guide:
http://gruntjs.com/getting-started
This is confusing as it seems to say that you are suppose to do a local install.
It seems contradictory actually. I clearly have a grunt file in place.
Grunt-cli is installed globally so that the grunt command is available to be run from any location on your system. Without the global installation, you would need to rely on somewhat abstract methods of running local grunt installs (npm run-script and friends), which are clunky for this use.
The entire point of the global install is only to load and run a local Gruntfile.js using the locally installed version of Grunt. The error message indicates this:
either a Gruntfile wasn't found or grunt hasn't been installed locally to your project.
In other words, to run Grunt, you need to create a Gruntfile.js and you must have a local copy of Grunt installed to your project alongside the file. The CLI is just there to kick off the process without troublesome fiddling.
I have a Grunt setup on my machine that's running SASS, Compass, Watch, Uglify... that kind of stuff. I've installed it using the command line (npm install...) from a tutorial.
I want to create a Grunt folder for another project. Is it okay to just copy that first folder and change the names? Is there some reason I should install the new one from the command line as well?
it will depends on what context you installed if was local or globally (-g).
If you installed locally without -g option, you are find to copy and past the folders.
However, would be a great practice to reuse only the package.json file and run the command, for your next project:
$ npm install
The install page on the Grunt website gives the following suggestion
Grunt and Grunt plugins should be defined as devDependencies in your
project's package.json. This will allow you to install all of your
project's dependencies with a single command: npm install.
I want to use grunt to run some tasks that are specific to local development, e.g.
development: concatenate javascript, but dont minify
production: concatenate and minify javascript
If I install Grunt as a dev dependency, does this mean when I run NPM install on the production server - grunt will not be installed into node modules?
What is the correct option to be able to use Grunt both locally and on the production server?
It doesn't matter if you install Grunt as a dev dependency, it will still be installed when you run npm install.
The scenario where dev dependencies are not installed is when you run npm install <package> because the consensus is you are an end user looking to use (not build/test) the package. However, you can still include the dev dependencies by adding the --dev flag.
You should install grunt with --save-dev. What it does is add a line to your project's package.json. Similar to when you install any other node module with --save-dev. Then, if you run npm install on any machine with the same package.json, all those modules will be downloaded and installed locally, and usable by your project.
As for running different tasks in production and development, I assume you know how to configure grunt to do that.
I am running grunt serve and when it exits and I try to run it again the port is taken and it won`t run. How do I exit so that the port is not taken?
I am trying out yeoman and I am not familiar to the tools it uses.
I'm using Ctrl+C to stop the grunt livereload server, that has newer given me that problem that it would not release the port.
Trying to set up Grunt with Roots Bootstrap Starter Template - Installation of grunt seemed to go perfectly fine - but when I run 'grunt watch' and go to change my .less files nothing happens in the terminal and grunt doesn't compile my changes. Here is my terminal output after installing > running grunt > and then running 'grunt watch'.
Jeffs-MacBook-Air:roots-master jeffsee55$ grunt
Running "clean:dist" (clean) task
Cleaning assets/css/main.min.css...OK
Cleaning assets/js/scripts.min.js...OK
Running "less:dist" (less) task
File assets/css/main.min.css created.
Running "uglify:dist" (uglify) task
File "assets/js/scripts.min.js" created.
Running "version" task
Versioning assets/css/main.min.css...OK
Versioning assets/js/scripts.min.js...OK
"lib/scripts.php" updated with new CSS/JS versions.
Done, without errors.
Jeffs-MacBook-Air:roots-master jeffsee55$ grunt watch
Running "watch" task
Waiting...
As I said, I then go to make changes to anything in ANY of my .less files which are located in assets/less. Any tips on troubleshooting? Perhaps reinstalling EVERYTHING including node.js?