【发布时间】:2018-02-18 16:14:56
【问题描述】:
我在 ubuntu 16.04 上安装了 nodejs,如下所示:
我在 apache 上运行它。
我的第一个应用程序 hello.js(保存在 /var/www/html/nodejs/ 中)是:
#!/usr/bin/env nodejs
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World! Node.js is working correctly!\n');
}).listen(8080);
console.log('Server running at http://localhost:8080/');
当我在浏览器中输入http://localhost:8080/ 我得到:
Hello World! Node.js is working correctly!
现在我想像这里建议的那样安装浏览器同步:
Using browser-sync with node.js app
但是当我跑步时:
$ sudo npm install browser-sync gulp --save-dev
我得到以下信息:
npm WARN registry Using stale data from https://registry.npmjs.org/ because the host is inaccessible -- are you offline?
npm WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm WARN deprecated graceful-fs@3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
> uws@9.14.0 install /home/sven/node_modules/uws
> node-gyp rebuild > build_log.txt 2>&1 || exit 0
sh: 1: cannot create build_log.txt: Permission denied
npm WARN saveError ENOENT: no such file or directory, open '/home/sven/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/home/sven/package.json'
npm WARN sven No description
npm WARN sven No repository field.
npm WARN sven No README data
npm WARN sven No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"ia32"})
+ browser-sync@2.23.6
+ gulp@3.9.1
added 547 packages in 57.958s
现在是否安装了浏览器同步?为什么我会收到这么多警告?这应该是这样的吗?我是 nodejs 的新手...
【问题讨论】:
-
是的,它已安装。
标签: node.js apache ubuntu-16.04