我刚刚读了Angularjs的教程,想从http://tinyurl.com/AngularJSDemos运行测试应用程序(由(C) Wahlin Consulting提供)。其自述文件告知:
NODE.JS OPTION:
If you want to run the site using Node.js (install it from http://nodejs.org) run the following at the command-prompt from within the AngularJSDemos folder:
node server.js
Now navigate to http://localhost:8080/DemoList.html or http://localhost:8080/CustomerManagementApp in your browser.我已经安装了nodejs,并尝试在我的Ubuntu系统中从终端启动它:
mainuser@mylaptop:~$ cd /home/mainuser/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos/
mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node server.js
The program 'node' can be found in the following packages:
* node
* nodejs-legacy
Try: sudo apt-get install <selected package>
mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ sudo apt-get install node
...
mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node server.js
mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node server.js
mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node
mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node ./server.js &
[1] 11153
mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node ./server.js
[1]+ Exit 1 node ./server.js
mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node ./server.js
mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ sudo apt-get install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
nodejs is already the newest version.
The following packages were automatically installed and are no longer required:
kde-l10n-engb kde-l10n-pl linux-headers-3.13.0-32
linux-headers-3.13.0-32-generic
Use 'apt-get autoremove' to remove them.
0 to upgrade, 0 to newly install, 0 to remove and 28 not to upgrade.
mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ 但是无论我做什么,我都不能启动这个示例。在Chrome中“此网页不可用”,在Firefox中“无法连接”。此外,看起来我根本不能在终端中启动它。
如何启动此示例?
发布于 2014-12-12 22:38:31
我建议使用nvm来安装node并在您的系统上管理不同的版本。
这很简单:
# First, we need to clone the nvm repository:
$ git clone https://github.com/creationix/nvm.git ~/.nvm
# Then, we need to add the following line to our .profile, .bashrc or .zshrc:
$ echo "source ~/.nvm/nvm.sh" >> .zshrc安装nvm是不够的,我们现在需要安装node & npm。
# To print out the list of all the available versions, simply run:
$ nvm ls-remote
# We want to install the current stable version which is v0.10.26, so we need to run:
The -s flag means we want to compile node from source.
$ nvm install -s v0.10.30当安装过程完成后,我们全新的节点和npm将被安装!nvm的伟大之处在于,您可以在每个shell实例中使用不同版本的node。但如果您想坚持使用最新版本,可以通过运行以下命令将其设置为默认版本:
$ nvm alias default 0.10.30通过键入node -v && npm -v确保一切都已启动并运行
发布于 2015-05-09 17:26:47
这里有一个不同的方法来解决这个问题,本教程建议使用npm,这是很好的。但这需要时间,互联网连接和设置。这是另一种方法,如果你已经在使用Ubuntu,python应该已经安装在你的系统中了。您的python安装已经附带了一个简单的HTTP服务器,您可以使用它来运行angular应用程序。
在控制台中,键入python -m SimpleHTTPServer 8080
然后将您的浏览器指向localhost:8080
并找到你的angular项目。那么它应该可以正常运行。
发布于 2015-05-09 17:36:22
您可能安装了incorrect node package。
多亏了这一点,您的node命令并不等同于nodejs,而是调用了完全不同的东西。
尝试使用
nodejs ./server.jshttps://stackoverflow.com/questions/27445846
复制相似问题