节点应用程序没有在我的PC上运行,但与我团队的其他PC运行良好(使用Git)

时间:2017-01-04 10:17:45

标签: node.js git npm travis-ci

我们的团队使用Node.js服务器创建项目,并使用Gi​​tHub作为源代码控制。问题是我将运行服务器。我使用后续步骤来测试主服务器是否将启动应用程序。

    class Order_History_ViewController: BASEVC,UITableViewDelegate ,UITableViewDataSource
     {
    @IBOutlet weak var tableview: UITableView!
    @IBOutlet weak var menu: UIButton!

var order : NSMutableArray = NSMutableArray()
var product : NSMutableArray = NSMutableArray()
var fruit1 = ["product_name":"Apple","unit":"500 gms","img":"fruit_apple.jpeg","price":"Rs.150","shop_name":"C.G.FOOD"]
var fruit2 = ["product_name":"Banana","unit":"12 pc","img":"fruit_banana.jpeg","price":"Rs.50","shop_name":"Fresh Supply"]
var fruit3 = ["product_name":"Cherry","unit":"250 gms","img":"fruit_cherry.jpeg","price":"Rs.60","shop_name":"C.G.FOOD"]
var fruit4 = ["product_name":"Grape","unit":"250 gms","img":"fruit_grape.jpeg","price":"Rs.30","shop_name":"C.G.FOOD"]
var fruit5 = ["product_name":"Mango","unit":"500 gms","img":"fruit_mango.jpeg","price":"Rs.100","shop_name":"Cayce Food"]
var order_date = ["Fri, March 11, 2016","Fri, March 04, 2016"]
var order_number = ["Order #246","Order #126"]
var price = ["Rs.390","Rs.330"]
var charge = ["Rs.50","Rs.50"]
var total = ["Rs.440","Rs.380"]
var Fees : Double = Double()
var btnHeaderTag : Int!
var upDownImageView : UIImageView = UIImageView()
var isImgChange : Bool = false

override func viewDidLoad()
{
    super.viewDidLoad()
    product.addObject(fruit1)
    product.addObject(fruit2)
    product.addObject(fruit3)
    product.addObject(fruit4)
    product.addObject(fruit5)
    let order1Dic : NSMutableDictionary = NSMutableDictionary()
    order1Dic["isExpandable"] = 0
    order1Dic["Data"] = product
    let order2Dic : NSMutableDictionary = NSMutableDictionary()
    order2Dic["isExpandable"] = 1
    order2Dic["Data"] = product
    order.addObject(order1Dic)
    order.addObject(order2Dic)
}

override func didReceiveMemoryWarning()
{
    super.didReceiveMemoryWarning()
}

func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat
{
    return 150
}

func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
{
    let view = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 100))
    //Header view
    let headerView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 49))
    let OrderDate = UILabel(frame: CGRect(x: 10, y: 10, width: 150, height: 30))
    OrderDate.textColor = UIColor(red: 24/255, green: 24/255, blue: 24/255, alpha: 1)
    OrderDate.font = UIFont(name: "JosefinSans-Regular_0.ttf", size: 23)
    OrderDate.text = order_date[section]
    headerView.addSubview(OrderDate)
    headerView.backgroundColor = UIColor(red: 198/255, green: 198/255, blue: 198/255, alpha: 1)
    upDownImageView = UIImageView(frame: CGRect(x: self.view.frame.width - 35, y: 23, width: 15, height: 10))
    upDownImageView.image = UIImage(named: "select_time_arrow")

    if self.btnHeaderTag != nil
    {
        if section == self.btnHeaderTag
        {
            if !self.isImgChange
            {
                upDownImageView.image = UIImage(named: "select_time_arrow")
            }
            else if self.isImgChange
            {
                upDownImageView.image = UIImage(named: "down_arrow")
            }
        }
    }

    headerView.addSubview(upDownImageView)
    let btn = UIButton(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 49))
    btn.addTarget(self, action: #selector(Order_History_ViewController.onHeaderClick(_:)), forControlEvents: .TouchUpInside)
    btn.tag = section
    print(btn.tag)
    headerView.addSubview(btn)


    view.addSubview(headerView)

    return view
}

func numberOfSectionsInTableView(tableView: UITableView) -> Int
{
    return order.count
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
    if btnHeaderTag != nil
    {
        if let isExpandable = self.order[btnHeaderTag].valueForKey(EXPANDABLE_KEY) as? Int
        {
            if section == btnHeaderTag
            {
                if isExpandable == 1
                {
                    // product details
                    if let _ = self.order[btnHeaderTag].valueForKey("Data") as? NSMutableArray
                    {
                        return product.count
                    }
                }
                else if isExpandable == 0
                {
                    return 0
                }
            }
        }
    }
    return 0
 }

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
    let cell = tableView.dequeueReusableCellWithIdentifier("history_cell", forIndexPath: indexPath)as!Cart_TableView_Cell
    let dataDict : NSDictionary = product[indexPath.row] as! NSDictionary

    cell.lblProduct_Name.text = dataDict["product_name"] as? String
    cell.lblShop_Name.text = dataDict["shop_name"] as? String
    cell.lblUnit.text =  dataDict["unit"] as? String
    cell.lblPrice.text = dataDict["price"] as? String
    let img = dataDict["img"] as? String
    cell.img_Product.image = UIImage(named:img!)

    return cell
}

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
}

func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath)
{

}

func onHeaderClick(button : UIButton)
{
    print("click")
    btnHeaderTag = button.tag
    print(btnHeaderTag)

    for (index,value) in self.order.enumerate()
    {
        if index == btnHeaderTag
        {
            if let isExpandable = value.valueForKey(EXPANDABLE_KEY) as? Int
            {
                if isExpandable == 0
                {
                    value.setValue(1, forKey: EXPANDABLE_KEY)
                    self.isImgChange = true
                }
                else
                {
                    value.setValue(0, forKey: EXPANDABLE_KEY)
                    self.isImgChange = false
                }
            }
        }
        else
        {
            value.setValue(0, forKey: EXPANDABLE_KEY)
        }
    }
    self.tableview.reloadData()
}

最后一条评论给了我下一个错误。

git checkout master
git pull
npm update
node .\backend\server.js

其他团队合作伙伴也在同一个存储库上工作,测试主服务器是否会运行。奇怪的问题是他们没有任何问题。 D:\***\node_modules\passport-oauth2\lib\strategy.js:82 if (!options.clientID) { throw new TypeError('OAuth2Strategy requires a clientID option'); } ^ TypeError: OAuth2Strategy requires a clientID option at Strategy.OAuth2Strategy (D:\Documenten\WatchFriends\Web\node_modules\passport-oauth2\lib\strategy.js:82:34) at new Strategy (D:\Documenten\WatchFriends\Web\node_modules\passport-google-oauth20\lib\strategy.js:52:18) at module.exports.config (D:\Documenten\WatchFriends\Web\backend\data\passport.js:94:18) at Object.<anonymous> (D:\Documenten\WatchFriends\Web\backend\server.js:16:1) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.runMain (module.js:604:10) at run (bootstrap_node.js:394:7) at startup (bootstrap_node.js:149:9) at bootstrap_node.js:509:3 文件忽略的配置文件也是相同的。

问题:为什么代码不会在我的计算机上运行但在其他计算机上运行会出现什么问题?

我已尝试从GitHub删除并重新启动项目,重新安装节点模块并添加了被忽略的文件。但它并没有解决错误。我正在使用节点版本6.9.3和git版本2.10.2.windows.1进行维护。

更新:

1 个答案:

答案 0 :(得分:1)

这就是为什么你应该使用像Travis,Circle或Codeship这样的持续集成系统来在干净的系统上运行你的测试 - 以避免应用程序无法运行但有人说&#34;它可以工作的情况我的系统&#34;。

显然,您的系统必须在某种程度上与代码所使用的系统不同。您可以安装不同的软件,运行不同的服务,使用不同的库,不同的环境变量,不同的操作系统,也可以在安装或启动应用程序时执行不同的操作。

开始使用CI,您就会立即发现错误。

也可以使用npm开始服务:

npm start

这样您就知道您正在运行与其他人相同的命令。