【问题标题】:Error when compiling using NPM使用 NPM 编译时出错
【发布时间】:2017-10-24 06:45:26
【问题描述】:

我是 angularjs 的新手,我有一个在 angular 框架中的项目文件,我目前是新的,我们实际上有两个文件,一个可以正常工作,但另一个不能,它们的其他项目文件上有一个 .bin 并且工作正常,我们目前正在修补的另一个没有 .bin 文件夹,我们如何生成 .bin 文件夹或如何修复如下所示的错误:

错误中的错误遇到静态解析符号值。调用函数 'ɵmakeDecorator',不支持函数调用。考虑用对导出函数的引用替换函数或 lambda,解析 C:/xampp/htdocs/my-app/node_modules/angular-datatables/node_modules/@angula r/core/core.d.ts 中的符号 NgModul e , 解析 C:/xampp/htdocs/my-app/no de_modules/angular-datatables/src/angular-datatables.module.d.ts 中的符号 DataTablesModule, 解析 C:/xampp/htdocs/my-app 中的符号 DataTablesModule /node_modules/angular-datatables/sr c/angular-datatables.module.d.ts

我在运行npm run ng serve 时收到错误消息“不是二进制文件等”。所以我将工作应用程序的bin 文件夹复制到当前应用程序,它能够运行命令,只有在这样做时我收到上面的错误消息。

这是package.json的内容:

{
  "name": "my-app",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.0.1",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "@types/datatables.net": "^1.10.1",
    "angular-datatables": "^4.1.0",
    "angular2-busy": "^2.0.3",
    "angular2-datatable": "^0.6.0",
    "angular2-highcharts": "^0.5.5",
    "angular2-notifications": "^0.4.53",
    "angulartics-google-analytics": "^0.4.0",
    "angulartics2": "^2.2.1",
    "chart.js": "^2.5.0",
    "core-js": "^2.4.1",
    "datatables.net": "^1.10.15",
    "datatables.net-dt": "^1.10.15",
    "jquery": "^3.2.1",
    "ng2-charts": "^1.5.0",
    "ng2-dropdown-multiselect": "^1.2.0",
    "ng2-select": "^1.2.0",
    "ng2-slim-loading-bar": "^4.0.0",
    "ng2-toastr": "^4.0.1",
    "ngDfp": "^0.16.0",
    "rxjs": "^5.1.0",
    "sweetalert2": "^6.5.6",
    "toastr-ng2": "^4.1.1",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0",
    "@angular/compiler-cli": "^4.0.0",
    "@types/datatables.net": "^1.10.1",
    "@types/jasmine": "2.5.38",
    "@types/jquery": "^2.0.45",
    "@types/node": "~6.0.60",
    "angular-2-dropdown-multiselect": "^1.1.0",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.5.0",
    "typescript": "~2.2.0"
  }
}

当我运行 npm start 时,我收到以下错误消息:

$ npm start

my-app@0.0.0 启动 C:\xampp\htdocs\my-app 服务

'ng' 不是内部或外部命令,可操作 程序或批处理文件。
npm 错误!代码 ELIFECYCLE npm 错误!错误号 1 npm 错误! my-app@0.0.0 开始:ng serve npm ERR!退出状态 1 npm 呃! npm 错误!在 my-app@0.0.0 启动脚本中失败。 npm 错误!这 可能不是 npm 的问题。可能有额外的日志记录 上面的输出。

npm 错误!可以在以下位置找到此运行的完整日志:npm ERR!
C:\Users\lboadilla\AppData\Roaming\npm-cache_logs\2017-05-24T05_42_53_038Z-debug.log

当我使用命令 npm install 我得到:

    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN angular2-datatable@0.6.0 requires a peer of @angular/core@^2.0.0 but none was installed.
npm WARN angular2-datatable@0.6.0 requires a peer of @angular/common@^2.0.0 but none was installed.
npm WARN angular2-datatable@0.6.0 requires a peer of @angular/platform-browser@^2.0.0 but none was installed.
npm WARN ng2-charts@1.5.0 requires a peer of @angular/common@^2.3.0 but none was installed.
npm WARN ng2-charts@1.5.0 requires a peer of @angular/core@^2.3.0 but none was installed.
npm WARN angulartics-google-analytics@0.4.0 requires a peer of angulartics@^1.0.0 but none was installed.
npm WARN toastr-ng2@4.1.1 requires a peer of @angular/core@^2.2.0 but none was installed.
npm WARN toastr-ng2@4.1.1 requires a peer of @angular/common@^2.2.0 but none was installed.
npm WARN angular2-notifications@0.4.53 requires a peer of @angular/core@^2.1.2 but none was installed.
npm WARN angular2-notifications@0.4.53 requires a peer of @angular/common@^2.1.2 but none was installed.
npm WARN angular2-notifications@0.4.53 requires a peer of @angular/platform-browser@^2.1.1 but none was installed.
npm WARN ng2-select@1.2.0 requires a peer of @angular/common@^2.3.0 but none was installed.
npm WARN ng2-select@1.2.0 requires a peer of @angular/core@^2.3.0 but none was installed.
npm WARN angular-2-dropdown-multiselect@1.3.2 requires a peer of tslib@^1.6.1 but none was installed.
npm WARN The package @types/datatables.net is included as both a dev and production dependency.

顺便说一句,我正在使用 windows。

【问题讨论】:

  • 您需要提供更多详细信息。您是否知道应用程序中使用的任何构建工具。 ng serve 很可能应该在您的浏览器上托管您的应用程序,前提是该应用程序附加了一个服务器。我相信您的应用程序中一定有一个package.json 文件。尝试发布它所说的内容。
  • @SaurabhTiwari 谢谢,我已添加供您参考,希望对您有所帮助
  • 它是一个 Angular 2 应用程序。我在您的问题中添加了angular 标签。
  • 你试过在这个应用的根目录运行npm start吗?
  • 这个项目似乎是一个 angular-cli 项目,但您的系统上似乎没有安装 angular-cli。尝试安装angular-cli。

标签: angular npm angular-cli npm-install


【解决方案1】:

为了安装 Angular cli,请使用以下命令

npm install -g @angular/cli@latest

全局包:

npm uninstall -g angular-cli @angular/cli
npm cache clean
npm install -g @angular/cli@latest

本地项目包:

rm -rf node_modules dist # On Windows use rmdir /s /q node_modules dist
npm install --save-dev @angular/cli@latest
npm install
ng init

【讨论】:

  • 这是在项目目录文件夹中与 package.json 内联吗?
  • 您好,安装后我收到此消息:npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\@angular\cli\node_modules\chokidar\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
  • 这不是错误。这是一个警告,即特定于 Mac OS 的 fseventsd 无法安装在 Linux 上。无需惊慌,需要 fsevents 的包仍然可以工作 - 这就是为什么它是可选依赖项。
  • 你现在可以试试运行吗
  • 它还说:npm WARN update-linked node_modules\@angular\cli needs updating to 1.0.4 from 1.1.0-beta.0 but we can't, as it's a symlink after我运行npm install -g @angular/cli@latest
猜你喜欢
  • 1970-01-01
  • 2020-06-25
  • 1970-01-01
  • 2017-11-22
  • 2016-10-27
  • 2016-05-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多