通过虚拟机上的localhost:port访问node.js/grunt服务器

o01*_*o01 20 virtual-machine node.js gruntjs

我正在通过Grunt在端口9000上本地运行node.js服务器.我还有一个运行的虚拟机(vmware),但我无法通过它访问节点服务器.我已经将VM配置为通过localhost访问主机上的Apache服务器,但是:9000给出了'not found'.

有人知道怎么做吗?

o01*_*o01 46

得到它了!在我的项目Grunt.js文件中有这样的设置:

grunt.initConfig({
    ...
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost'
      },
    }
    ...
  });
Run Code Online (Sandbox Code Playgroud)

我所要做的就是改变localhost0.0.0.0并重新启动grunt server.