如何安装在Windows 7角 [英] How do you install Angular on windows 7

查看:206
本文介绍了如何安装在Windows 7角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这应该是pretty直线前进,但我被卡住。我的机器在Windows 7计算机上安装的Buildbot(0.9.06b)。我设法得到它,并运行但是当我尝试显示网页(IE8),我得到的错误角没有定义。这是一个全新的Windows中,我不是太惊讶。我接着下载的的NodeJS可执行程序,因此安装节点的计算机上运行它。然后我去角网站下载的zip文件,但我不知道下一步该怎么做?
我试过

Hi this should be pretty straight forward but I'm getting stuck. I installed buildbot (0.9.06b)on my machine a Windows 7 machine. I have managed to get it up and running however when I try to display the web page(IE8), I get the error Angular not defined. This being a brand new windows box I was not too surprised. I proceeded to download NodeJS the executable and run it on the machine so Node is installed. I then went to Angular website downloaded the zip file, but i'm not sure what to do next? I tried

NPM安装角

和即指定版本,解压文件中的一些变化。但仍不能安装它。
我的机器是在防火墙后面,因此它不能只是走下车来的网页,并获得更多的东西。这一切都在本地工作。
我应该如何去安装角?
如何检查是否安装角?

and a few variations i.e specifying the version, unzipping the file. But still cannot install it. My machine is behind a firewall so it cannot just go off to the web and get more stuff. It all has to work locally. How should I go about installing Angular? How can I check that Angular is installed?

问候

推荐答案

为例使用节点,棱角分明,前$工作程序本GitHub库 p $ PSS和鲍尔。

TL;DR

Checkout this github repo for an example working app using Node, Angular, Express and Bower.

在你的理由接受角不定义的消息是因为你没有提供从Web服务器到客户端角。

The you're reason receiving the Angular not defined message is because you're not serving Angular from your web server to the client.

NPM 安装角通常意味着你会从你的 node_modules 文件夹服务,或你会要使用 Browserify 。我会建议不要使用 NPM安装--save角,您 node_modules 应该只包含服务器端相关性,如果你'再在大多数情况下,不使用Browserify。此外,NPM包使用CommonJS的,这是不是在浏览器 pferred $ P $。 Browserify是编写CommonJS的风格code,它可以捆绑成一个浏览器兼容的JS文件一个流行的解决方案。他们有文档起床和运行。

Installing Angular from npm typically means that you're going to serve it from your node_modules folder or you will be using Browserify. I would advise against using npm install --save angular, your node_modules should contain just server-side dependencies if you're not using Browserify in most cases. Additionally, NPM packages use CommonJS, which isn't preferred in the browser. Browserify is a popular solution for writing CommonJS style code that can be bundled into a browser compatible js file. They have docs to get up and running with.

另外,你可以安装 Bower.io 角。鲍尔是客户端软件包的软件包管理器。鲍尔有一个巨大的封装库,其中包括许多也可通过故宫的包。

Alternatively you can install Angular from Bower.io. Bower is a package manager for client-side packages. Bower has a huge package library, including many of the packages that are also available through NPM.

其还值得一提的是,除非你做一个 NPM安装-g 全球安装,您应该添加 - 保存标志做一个 NPM安装或 NPM卸载为您的项目依赖。 - 保存将您已经安装到你的的package.json 文件作为依赖的软件包。

Its also worth mentioning that unless you're doing a npm install -g for global installs, you should add the --save flag when doing an npm install or an npm uninstall for your project dependencies. --save adds any packages you've installed to your package.json file as dependency.

本例使用Node.js的,前preSS,EJS(防爆preSS视图引擎渲染),鲍尔和放大器;角

This example just uses Node.js, Express, EJS (for Express View Engine Rendering), Bower & Angular

npm install -g bower
cd <your project directory>  

// answer questions about your project
// this will create your package.json file
npm init 
npm install --save express
npm install --save ejs

// answer the questions about your project
// this will create your bower.json file
bower init 
bower install --save angular  

目录结构

- Project Folder
  - node_modules
  - bower_components
  - public
    - app
      - app.js
  - views
    - index.html
  - bower.json
  - package.json
  - server.js

的角应用程序 - 公开/应用/ app.js

// This is a super simple Hello World AngularJS App
(function() {
  angular
    .module('yourApp', [])
    .controller('YourController', ['$scope', function($scope) {         
      $scope.hello = 'Hello World';
    }]);
})();

角必须加载就像任何其他客户端库,所以它需要包含在在您的网页&LT;头方式&gt; 标记

视图 - 观点/ index.html的

<html>
  <head>
    <!-- load Angular into our HTML Page -->
    <script src="/bower_components/angular/angular.js"></script>
    <!-- load our Angular App in -->
    <script src="/public/app/app.js"></script>
  </head>
  <body ng-app="yourApp">
    <div ng-controller="YourController">
      {{ hello }}
    </div>
  </body>
</html>

为了这个工作,你需要实际上有一个Web服务器正在运行,这将有助于你在寻找,当你打电话给他们的文件。为此,您可以使用前preSS

In order for this to work you will need to actually have a web server running that will serve the files you're looking for when you call them. You can do this using Express.

Node.js的Web服务器 - server.js

var express = require('express);
var path = require('path');
var app = express();


// Setup View Engines
app.set('views', path.join(__dirname, 'views'));
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');

// Serve files from your "public" directory
app.use('/public', express.static(path.join(__dirname + 'public)));

// Serve files from your "bower_components" directory
app.use('/bower_components', express.static(path.join(__dirname + '/bower_components')));

// GET index.html route
app.get('/', function(req, res) {
  return res.render('index');
});

// Start our server and start to listen
app.listen(process.env.PORT || 3000, function() {
  console.log('listening');
});

现在,所有你需要做的就是节点server.js 本地主机或你'访问您的网站已经规定,你应该启动并运行。

Now all you need to do is node server.js and visit your site at localhost or wherever you've specified and you should be up and running.

这篇关于如何安装在Windows 7角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆