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
答案 0 :(得分:1)
grunt
is 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 using pm2
or forever
or something else instead of grunt
.
As far as getting grunt
running 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 grunt
if it finds itself in a non-global path.
Note that Option 1 doesn't require superuser privileges.
From a shell in your home directory, you can install grunt-cli
in without the -g
. Then use a shell alias or your PATH
environment variable so that you run grunt from ~/node_modules/.bin/grunt
.
If you have superuser privileges, change the permissions on the global node_modules
directory 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...
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.