gpt4 book ai didi

angularjs - 在 Ubuntu 中启动 Nodejs/Angularjs 应用程序

转载 作者:行者123 更新时间:2023-12-04 19:03:07 24 4
gpt4 key购买 nike

我刚刚阅读了关于 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 中“无法连接”。此外,看起来我根本无法在终端中启动它。

如何启动这个例子?

最佳答案

我建议使用 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

安装过程完成后,将安装我们全新的 Node 和 npm!
nvm 的好处是您可以在每个 shell 实例中使用不同版本的 Node 。但是,如果您想坚持使用最新版本,可以通过运行将其设置为默认值:
$ nvm alias default 0.10.30

通过键入 node -v && npm -v 确保一切正常运行

关于angularjs - 在 Ubuntu 中启动 Nodejs/Angularjs 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27445846/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com