Getting error while running simple javascript using node framework

前端 未结 8 2002
闹比i
闹比i 2021-01-30 06:25

As I run this piece of code using node a.js:

var sys = require(\'sys\');
sys.puts(\'Hello, World\');

I\'m getting the following as a

8条回答
  •  温柔的废话
    2021-01-30 06:58

    If Node.js installation as suggested by ninja works for you (like on AWS Ubuntu):

    sudo apt-get update
    sudo apt-get install python-software-properties
    sudo add-apt-repository ppa:chris-lea/node.js
    sudo apt-get update
    sudo apt-get install nodejs
    

    you might still want to add node to your system path like this:

    export PATH=/usr/bin/:$PATH
    

    so you can type

    node webapp.js
    

    instead of

    /usr/bin/node webapp.js
    

    Find your node installation path simply by typing

    which node
    

提交回复
热议问题