【问题标题】:How to run a AngularJS project in 2019?如何在 2019 年运行 AngularJS 项目?
【发布时间】:2019-08-29 03:11:35
【问题描述】:

我想运行一个由 Angular 1.5 编写的项目,我知道这是 gulp 的午餐。首先我使用npm install 安装所有依赖项,然后使用gulp 运行它。但失败了。它给了我800个问题。他们中的大多数看起来像:

 226:7   error You should not set properties on $scope in controllers. Use controllerAs syntax and add data to "this"  angular/controller-as
 292:26  error  "$" is not defined   
 334:19  warning  You should use angular.element instead of the jQuery $ object 
 18:11   error    You should not set properties on $scope in controllers. Use controllerAs syntax and add data to "this"  angular/controller-as

但代码在其他计算机上运行良好。所以我想这不是代码的问题。我一定错过了什么。只想运行它。请帮助我,任何信息都会有所帮助。

我还创建了另外一件事,当我使用 npm install 安装依赖项时,它给了我一些错误,所以它没有安装所有依赖项。错误是这样的:

gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir     '/Users/jzhu321/Desktop/PwC/Projects/TeamTrack_Project/TeamTrack_Angular/node_modules/utf-8-validate/build'
gyp ERR! System Darwin 18.5.0
gyp ERR! command "/usr/local/bin/node"     "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js"     "rebuild"
gyp ERR! cwd /Users/xxxx/Desktop/xx/Projects/xxxx_Project/xxxx_Angular/node_modules/utf-8-validate
gyp ERR! node -v v10.15.2
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

我已经厌倦了某种方法来修复它(chomd 777 directName..)但是。不工作。

【问题讨论】:

    标签: javascript node.js gulp node-gyp angular1.6


    【解决方案1】:

    简答:用nvm 让时间倒流。

    这看起来很像 node.js 版本问题。你正在运行 Node 的 v10.x,我敢打赌这个应用程序是在 v0.x 天重新构建的,在 Node 切换到他们的 great release schedule 之前。

    Node-gyp 特别有问题。它编译模块,所以它基本上是在尝试编译不是为之设计的东西。

    尝试找出您的 JS 是何时编写的,并将 Node 版本与该时间段相匹配。您可以使用 nvm 运行多个版本的 Node.js。这可能很痛苦,但它正是您所需要的 - 帮助您的 JS 时光倒流回到构建此应用程序的时间。

    在您的应用上运行 npm install 之前进入您的终端,并设置正确的旧版本 Node.js,以便使用 nvm use 4 或您需要的任何版本运行您的应用。

    然后,您将经历一个漫长而痛苦的过程,更新模块并看着事情发生故障,直到您可以对应用程序进行现代化改造。

    【讨论】:

      猜你喜欢
      • 2019-09-08
      • 1970-01-01
      • 2016-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-17
      • 2020-04-21
      • 2015-06-14
      相关资源
      最近更新 更多