I have developed a website on Node.js that runs perfectly on my local machine. I run my server with the command:
$ grunt serve
The problem is when i run my web application on my server online ( gandi server ). I can't use the command
$ grunt serve
Because i should install the package '' grunt-cli ''wich :
$ npm install -g grunt-cli
On server Gandi.net, i can't install global package, then i don't use the command
$ grunt
I try a program like
var grunt = require('grunt');
grunt.task.run("serve");
Program don't run.
I need help for run my grunt task '' serve '' without grunt -cli
Option 0
gruntis a build tool and is generally not used to run servers other than local test servers. So the best solution is probably to get your server up and running usingpm2orforeveror something else instead ofgrunt.As far as getting
gruntrunning on the server, if you still need to do that, you have a few options.Option 1 is the least disruptive to the system but may require the most understanding on your part to pull off successfully. Specifically, I'm not sure how much grief you will get from
gruntif it finds itself in a non-global path.Note that Option 1 doesn't require superuser privileges.
Option 1
From a shell in your home directory, you can install
grunt-cliin without the-g. Then use a shell alias or yourPATHenvironment variable so that you run grunt from~/node_modules/.bin/grunt.Option 2
If you have superuser privileges, change the permissions on the global
node_modulesdirectory so that you have write access to it.Some people recommend this over the next option for security reasons, but I think most people probably just go right to...
Option 3
If you have permission to do so on your server, you can use
sudo npm install -g grunt-cli.Option 3 is the easiest but also requires the most trust in the packages that you are installing. Because a package can do anything once you start installing it with
sudo, only use this option on packages you inspect and/or trust.