node.js安装错误require('http');

时间:2021-09-19 18:30:24

I'm installing node.js on Ubuntu as per these instructions ( http://nodenode.com/post/1197688151/installing-node-js-on-ubuntu-screencast-tutorial )

我按照这些说明在Ubuntu上安装node.js(http://nodenode.com/post/1197688151/installing-node-js-on-ubuntu-screencast-tutorial)

and I'm recieving the following errors on the final step

我在最后一步收到了以下错误

I type node hello_node.js

我键入节点hello_node.js

my terminal replies

我的终端回复

/home/joe/tmp/hello_node/hello_node.js:1
require(‘http’);
    ^

 node.js:201
    throw e; // process.nextTick error, or 'error' event on first tick
          ^
 SyntaxError: Unexpected token ILLEGAL
     at Module._compile (module.js:427:25)
      at Object..js (module.js:450:10)
  at Module.load (module.js:351:31)
  at Function._load (module.js:310:12)
  at Array.0 (module.js:470:10)
  at EventEmitter._tickCallback (node.js:192:40)

So, it seems I 'require' http. Am I doing something wrong... or worse, stupid?

所以,似乎我'需要'http。我做错了什么......或者更糟糕的是,愚蠢的?

1 个解决方案

#1


3  

You're not using normal single quotes. You have:

你没有使用普通的单引号。你有:

require(‘http’);

It should be:

它应该是:

require('http');

#1


3  

You're not using normal single quotes. You have:

你没有使用普通的单引号。你有:

require(‘http’);

It should be:

它应该是:

require('http');