Angular 6错误无法从.../node_modules/@angular/core/core.d.ts解析./src/util/decorators的原始符号 [英] Angular 6 ERROR in Couldn't resolve original symbol for ./src/util/decorators from .../node_modules/@angular/core/core.d.ts

查看:78
本文介绍了Angular 6错误无法从.../node_modules/@angular/core/core.d.ts解析./src/util/decorators的原始符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试运行以下命令来构建要用于生产的项目,并收到该主题中所述的错误:

I try to run the following to build my project for production and receive the error as stated in the subject:

ng build --prod

当我查看core.d.ts文件时,找不到以下内容:

When I look in the core.d.ts file, it cannot find the following:

"./src/change_detection/differs/default_iterable_differ";
"./src/profile/profile";
"./src/util/decorators";

以下是整个文件:

    /**
 * Generated bundle index. Do not edit.
 */
export * from "./index";
export {
  APPLICATION_MODULE_PROVIDERS as ɵangular_packages_core_core_l,
  _iterableDiffersFactory as ɵangular_packages_core_core_i,
  _keyValueDiffersFactory as ɵangular_packages_core_core_j,
  _localeFactory as ɵangular_packages_core_core_k
} from "./src/application_module";
export {
  _appIdRandomProviderFactory as ɵangular_packages_core_core_f
} from "./src/application_tokens";
export {
  DefaultIterableDifferFactory as ɵangular_packages_core_core_g
} from "./src/change_detection/differs/default_iterable_differ";
export {
  DefaultKeyValueDifferFactory as ɵangular_packages_core_core_h
} from "./src/change_detection/differs/default_keyvalue_differ";
export {
  ReflectiveInjector_ as ɵangular_packages_core_core_c
} from "./src/di/reflective_injector";
export {
  ReflectiveDependency as ɵangular_packages_core_core_d,
  resolveReflectiveProviders as ɵangular_packages_core_core_e
} from "./src/di/reflective_provider";
export {
  wtfEnabled as ɵangular_packages_core_core_m
} from "./src/profile/profile";
export {
  createScope as ɵangular_packages_core_core_o,
  detectWTF as ɵangular_packages_core_core_n,
  endTimeRange as ɵangular_packages_core_core_r,
  leave as ɵangular_packages_core_core_p,
  startTimeRange as ɵangular_packages_core_core_q
} from "./src/profile/wtf_impl";
export {
  getOrCreateChangeDetectorRef as ɵangular_packages_core_core_v,
  getOrCreateContainerRef as ɵangular_packages_core_core_y,
  getOrCreateElementRef as ɵangular_packages_core_core_x,
  getOrCreateInjectable as ɵangular_packages_core_core_w,
  getOrCreateNodeInjector as ɵangular_packages_core_core_u,
  getOrCreateTemplateRef as ɵangular_packages_core_core_z
} from "./src/render3/di";
export {
  bindingUpdated as ɵangular_packages_core_core_ba
} from "./src/render3/instructions";
export {
  loadInternal as ɵangular_packages_core_core_bb
} from "./src/render3/util";
export {
  makeParamDecorator as ɵangular_packages_core_core_a,
  makePropDecorator as ɵangular_packages_core_core_b
} from "./src/util/decorators";
export { _def as ɵangular_packages_core_core_s } from "./src/view/provider";
export {
  DebugContext as ɵangular_packages_core_core_t
} from "./src/view/types";

我可以运行npm我的装饰器吗?如果我运行以下命令:

Do I run npm i decorators? If I run the following:

ng serve --disable-host-check

更正为原始帖子-现在该项目根本无法运行.发生了什么?我已经进行了一个多月的测试,现在可以开始使用了,尝试创建dist目录后,它根本无法使用.WTF?

Correction to original post - now the project does not run at all. What happened? I have been testing this thing for over a month and, now that I am ready to go live, it just does not work at all after trying to create a dist directory. WTF?

以下是我在控制台中看到的内容:

The following is what I am seeing in the console:

TypeError: Class constructor Subject cannot be invoked without 'new'
at new EventEmitter (core.umd.js:3597)
at new NgZone (core.umd.js:3745)
at getNgZone (core.umd.js:4473)
at PlatformRef.push../node_modules/@angular/core/bundles/core.umd.js.PlatformRef.bootstrapModuleFactory (core.umd.js:4369)
at core.umd.js:4415
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138)
at zone.js:872
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)

当我运行ng build时,我看到以下内容:

When I run ng build I am seeing the following:

ng build --prod

Date: 2019-02-02T23:59:21.603Z
Hash: 51184dcdbc91f92a675d
Time: 3998ms
chunk {0} runtime.6afe30102d8fe7337431.js (runtime) 1.05 kB [entry] [rendered]
chunk {1} styles.42d170ae18051bd9f923.css (styles) 177 kB [initial] [rendered]
chunk {2} polyfills.03b06938f23b8f1cb153.js (polyfills) 130 bytes [initial] [rendered]
chunk {3} main.541dbdbf0b123b4c3be8.js (main) 128 bytes [initial] [rendered]

ERROR in Couldn't resolve original symbol for ./src/util/decorators from /Applications/MAMP/htdocs/oshop/node_modules/@angular/core/core.d.ts

顺便说一句,现在在app.module.ts中,它找不到HttpClientModule或HTTP_INTERCEPTORS的模块

BTW, now in app.module.ts, it cannot find module for HttpClientModule or HTTP_INTERCEPTORS

Cannot find module '@angular/common/http' 

当我尝试重新安装@ angular/common时:

When I try to re-install @angular/common:

sudo npm i -g @angular/common^6.1.10
npm ERR! code ENOLOCAL
npm ERR! Could not install from "@angular/common^6.1.10" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/tam3/.npm/_logs/2019-02-03T02_29_27_361Z-debug.log

但是它在package.json中:

But it is in the package.json:

"devDependencies": {
  "@angular-devkit/build-angular": "~0.7.0",
  "@angular/cli": "~6.1.0",
  "@angular/common": "~6.1.10",
  "@angular/compiler-cli": "^6.1.0",
  "@angular/core": "^6.1.10",

WTF,我遵循一条帖子,该帖子建议我要做的就是删除node_modules目录,然后进行npm install,它将重新安装所有内容.我能做些什么?我真的已经准备好今天开始直播

WTF, I followed a post that suggested all I had to do was to trash the node_modules directory, followed by npm install and it would reinstall everything. What can I do? I literally was ready to go live today

预先感谢

推荐答案

我能够通过解决其他首先,我必须确保不再在.npm-global中安装npm,这样做是为了避免在每次/任何安装之前都不再键入sudo,但这是有代价的,我在上述文章中对此进行了概述.

First, I had to make sure that the npm(s) were no longer being installed in .npm-global, which I had done to get around no longer typing sudo before every/any install, but that came at a price, which I outline in the aforementioned post.

第二,我关注了stackoverflow上的其他几篇文章,这些文章指示我将package.json文件中的依赖项更改为以下内容:

Second, I followed a couple of other posts on stackoverflow that instructed me to change my dependencies in the package.json file to the following:

"rxjs": "6.0.0",
"typescript": "^2.7.2",

接着删除node_modules目录,然后进行npm安装,但这只能奏效,因为我的npm安装不再安装在〜/.npm-global中.

Followed by deleting the node_modules directory, then do an npm install, but this only worked because my npm installs were no longer being installed in ~/.npm-global.

此外,正如我在另一篇文章中所述,该构建仍然无法正常工作,但这是因为还有很多其他错误需要我解决,但至少这个问题已经解决了,而且我的系统回到此错误弹出之前的位置.

Also, as I stated in the other post, the build is still not working, but that is because there are so many other errors that I have to resolve going forward, but at least this issue is out of way and my system is back to where it was before this error popped up.

这些是我所指的一些向前发展的错误:

These are some of the errors moving forward that I am referring to:

Property 'value' does not exist on type 'HTMLElement'
Property 'shoppingCart' does not exist on type {}

这篇关于Angular 6错误无法从.../node_modules/@angular/core/core.d.ts解析./src/util/decorators的原始符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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