GVKun编程网logo

angularjs – 错误:无法解析’child_process’Angular-cli(无法解析jstl)

13

此处将为大家介绍关于angularjs–错误:无法解析’child_process’Angular-cli的详细内容,并且为您解答有关无法解析jstl的相关问题,此外,我们还将为您介绍关于Angula

此处将为大家介绍关于angularjs – 错误:无法解析’child_process’Angular-cli的详细内容,并且为您解答有关无法解析jstl的相关问题,此外,我们还将为您介绍关于Angular 11:- 找不到模块:错误:无法解析'../../../../node_modules/@angular/forms/forms'、Angular AOT&Rollup – 无法解析’app.module.ngfactory’、Angular NgUpgrade将AngularJS服务注入Angular服务;获取:未处理的Promise拒绝:无法读取未定义的属性’get’;区:、angular – Webpack bootstrap-loader错误:无法解析’./bootstrap-styles’并且无法解析’./bootstrap-scripts’的有用信息。

本文目录一览:

angularjs – 错误:无法解析’child_process’Angular-cli(无法解析jstl)

angularjs – 错误:无法解析’child_process’Angular-cli(无法解析jstl)

我使用angular-cli生成了一个新的应用程序并添加了一些组件.我没有添加任何测试用例.当我尝试运行/构建应用程序时,我收到以下冗长的错误消息:

ERROR in ./node_modules/selenium-webdriver/firefox/binary.js
Module not found: Error: Can't resolve 'child_process' in '/home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/firefox'
resolve 'child_process' in '/home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/firefox'
  Parsed request is a module
  using description file: /home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/package.json (relative path: ./firefox)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/package.json (relative path: ./firefox)
    resolve as module
      /home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/firefox/node_modules doesn't exist or is not a directory
      /home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/node_modules doesn't exist or is not a directory
      /home/myName/PROJECTS/MEAN/fruit-stall/node_modules doesn't exist or is not a directory
      /home/myName/PROJECTS/MEAN/node_modules doesn't exist or is not a directory
      /home/myName/PROJECTS/node_modules doesn't exist or is not a directory
      /home/myName/node_modules doesn't exist or is not a directory
      /home/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/node_modules
        using description file: /home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/package.json (relative path: ./node_modules)

请找到详细的转储here.

操作系统:Ubuntu 16.04 LTS
Angular版本是:5.0.2
节点:9.2.0

我还发现了一个类似的问题被问到here,但它与测试用例有关.由于我没有编写任何测试用例,这对我没有帮助.

解决方法

有罪魁祸首!

我正在从selenium而不是angular-core中添加一些事件给组件和visual studio代码导入的事件发射器.

删除了这个

import { EventEmitter } from 'selenium-webdriver';

并更新了这个:

import { Component,OnInit,Input,EventEmitter } from '@angular/core';

Angular 11:- 找不到模块:错误:无法解析'../../../../node_modules/@angular/forms/forms'

Angular 11:- 找不到模块:错误:无法解析'../../../../node_modules/@angular/forms/forms'

如何解决Angular 11:- 找不到模块:错误:无法解析''../../../../node_modules/@angular/forms/forms''?

我正在尝试使用 angular 11 中的表单,但出现以下错误- 错误:./src/app/components/register/register.component.ts 找不到模块:错误:无法解析“C:\Users\Ram Chaurasiya\Desktop\Projects\MyRealtimeProjects\onlineLearningPortal\”中的“../../../../node_modules/@angular/forms/forms” src\app\components\register''

解决方法

请在 register.component.ts 中检查您的导入 它应该仅来自“@angular/forms”

Angular AOT&Rollup – 无法解析’app.module.ngfactory’

Angular AOT&Rollup – 无法解析’app.module.ngfactory’

我想完成Angular的AOT教程:
https://angular.io/docs/ts/latest/cookbook/aot-compiler.html

使用ngc部件工作,它生成一个文件夹.
但是,当涉及到使用汇总部分的树摇动时,我遇到了这个错误:

Error: Could not resolve '../aot/app/app.module.ngfactory' from ...\app\main-aot.js
    at Error (native)
    at ...\node_modules\rollup-plugin-node-resolve\dist\rollup-plugin-node-resolve.cjs.js:78:21
    at ...\node_modules\resolve\lib\async.js:56:18
    at load (...\node_modules\resolve\lib\async.js:70:43)
    at onex (...\node_modules\resolve\lib\async.js:93:31)
    at ...\node_modules\resolve\lib\async.js:23:47
    at FSReqWrap.oncomplete (fs.js:82:15)

我错过了什么吗?

@angular:2.4.4
汇总:0.41.4

解决方法

Angular的AOT教程似乎缺少一步;使用ngc后,它只在aot文件夹中生成ts文件.下一步,您需要再次编译这些文件,以生成必要的js文件.

这里有两个重要的注释:

>您需要将这些ts文件编译为es2015模块,以便从“树摇动”中受益.这意味着必须有一个仅指向main-aot.ts文件的配置文件(tsconfig-compile-aot.json).
>在步骤1之后,项目中的所有相关ts文件将编译为es2015模块.如果你在开发环境中使用systemjs作为模块加载器和commonjs模块(如在Angular的教程中),在使用汇总之后,你需要再次将你的ts文件编译为commonjs模块,以避免系统问题.

以下是确切的步骤:

>使用ngc和tsconfig-aot.json将app.module编译为a20文件夹作为es2015模块.
>使用tsc和tsconfig-compile-aot.json编译main-aot.ts文件,再次作为es2015模块并生成js文件.
>将您的输入文件(main-aot.js)传递给汇总.现在它应该生成你的输出文件没有任何错误.
>如果要继续使用systemjs进行开发,请使用tsconfig.json编译app / ts文件,将它们再次转换为commonjs模块.

我创建了一个使用以下步骤的演示应用程序:
https://github.com/forCrowd/Labs-Angular-AOTConfiguration

>安装节点包
>运行gulp – 默认任务
>打开index.html for“Development – SystemJS”案例
>打开index-aot.html进行“生产 – AOT& Rollup Tree-shaking”案例

它还包含build-invalid gulp任务,跳过第二步,表明它导致“无法解析’app.module.ngfactory’”错误.

Angular NgUpgrade将AngularJS服务注入Angular服务;获取:未处理的Promise拒绝:无法读取未定义的属性’get’;区:

Angular NgUpgrade将AngularJS服务注入Angular服务;获取:未处理的Promise拒绝:无法读取未定义的属性’get’;区:

我在这里看到了很多类似的问题,但还没有找到一个有效的解决方案.我认为正在发生的是,因为我们的Ng2App首先被引导,它还没有引用$injector,所以当我尝试在我的提供者声明(deps:[‘$injector’])中使用它时,它没有’存在.

什么是INSANELY奇怪的是我可以在Angular COMPONENT中使用此服务但由于某种原因无法在Angular SERVICE中使用它.

app.js

import UserService from './user.service';
angular.module('app',[])
  .service('UserService',UserService)
  .config(/* config */)
  .run(/* run */);

 import './ng2app.module';

ng2app.module.ts:

import { browserModule } from '@angular/platform-browser';
import { UpgradeModule } from '@angular/upgrade/static';
import { platformbrowserDynamic } from '@angular/platform-browser-dynamic';
@NgModule({
  imports: [
    browserModule,UpgradeModule,],declarations: [],entryComponents: [],providers: [
    // angularJS service:
    { 
     provide: 'UserService',useFactory: (i: any) => i.get('UserService'),// <---- this is the line all the errors point to.
     deps: ['$injector']
    },]
})
export default class Ng2AppModule {
  constructor(){}
}


platformbrowserDynamic()
  .bootstrapModule(Ng2AppModule)
  .then(platformRef => {
    const upgrade = platformRef.injector.get(UpgradeModule) as UpgradeModule;
    upgrade.bootstrap(document.documentElement,['app'],{strictDi: true});
});

后来…在服务中(失败):

import {Injectable,Inject} from "@angular/core";
import UserService from 'app/login/user.service';

@Injectable()
export class AnAngularservice{
  constructor(
    // causes the error if I uncomment it wtf: <--------------
    // @Inject('UserService') private userService: UserService
  ){}
}

稍后……在一个组件中(正常工作):

import { Component } from '@angular/core';
import {Inject} from "@angular/core";
import UserService from 'app/login/user.service';
import template from 'tmpl.html';

@Component({
  selector: 'an-angular-component',template,})
export class AnAngularComponent{
  constructor(

    @Inject('UserService') private userService: UserService
  ){
    console.log(userService) // works just fine. wtf <--------------
  }
}

有谁知道为什么会这样,以及如何解决它?

This question is almost exactly the same thing but for some reason it didnt work

AngularJS版本:1.5.8
角/核心等版本:4.2.4

Here’s a link to the Github issue I opened in the Angular repo

堆栈跟踪:

zone.js:522 Unhandled Promise rejection: Cannot read property 'get' of undefined ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot read property 'get' of undefined
    at useFactory (ng2app.module.ts:114)
    at _callFactory (core.es5.js:9604)
    at _createProviderInstance$1 (core.es5.js:9547)
    at initNgModule (core.es5.js:9498)
    at new NgModuleRef_ (core.es5.js:10606)
    at createNgModuleRef (core.es5.js:10590)
    at Object.debugCreateNgModuleRef [as createNgModuleRef] (core.es5.js:12874)
    at NgModuleFactory_.create (core.es5.js:13869)
    at core.es5.js:4556
    at ZoneDelegate.invoke (zone.js:334)
    at Object.onInvoke (core.es5.js:3933)
    at ZoneDelegate.invoke (zone.js:333)
    at Zone.run (zone.js:126)
    at ngzone.run (core.es5.js:3801)
    at PlatformRef_._bootstrapModuleFactoryWithZone (core.es5.js:4554)
    at core.es5.js:4596
    at ZoneDelegate.invoke (zone.js:334)
    at Zone.run (zone.js:126)
    at zone.js:713
    at ZoneDelegate.invokeTask (zone.js:367)
    at Zone.runTask (zone.js:166)
    at drainMicroTaskQueue (zone.js:546)
    at <anonymous> TypeError: Cannot read property 'get' of undefined
    at useFactory (http://localhost:9000/app.bundle.js:4404:52)
    at _callFactory (http://localhost:9000/vendor.bundle.js:10600:26)
    at _createProviderInstance$1 (http://localhost:9000/vendor.bundle.js:10543:26)
    at initNgModule (http://localhost:9000/vendor.bundle.js:10494:13)
    at new NgModuleRef_ (http://localhost:9000/vendor.bundle.js:11602:9)
    at createNgModuleRef (http://localhost:9000/vendor.bundle.js:11586:12)
    at Object.debugCreateNgModuleRef [as createNgModuleRef] (http://localhost:9000/vendor.bundle.js:13870:12)
    at NgModuleFactory_.create (http://localhost:9000/vendor.bundle.js:14865:25)
    at http://localhost:9000/vendor.bundle.js:5552:61
    at ZoneDelegate.invoke (http://localhost:9000/vendor.bundle.js:289131:26)
    at Object.onInvoke (http://localhost:9000/vendor.bundle.js:4929:37)
    at ZoneDelegate.invoke (http://localhost:9000/vendor.bundle.js:289130:32)
    at Zone.run (http://localhost:9000/vendor.bundle.js:288923:43)
    at ngzone.run (http://localhost:9000/vendor.bundle.js:4797:62)
    at PlatformRef_._bootstrapModuleFactoryWithZone (http://localhost:9000/vendor.bundle.js:5550:23)
    at http://localhost:9000/vendor.bundle.js:5592:59
    at ZoneDelegate.invoke (http://localhost:9000/vendor.bundle.js:289131:26)
    at Zone.run (http://localhost:9000/vendor.bundle.js:288923:43)
    at http://localhost:9000/vendor.bundle.js:289510:57
    at ZoneDelegate.invokeTask (http://localhost:9000/vendor.bundle.js:289164:31)
    at Zone.runTask (http://localhost:9000/vendor.bundle.js:288963:47)
    at drainMicroTaskQueue (http://localhost:9000/vendor.bundle.js:289343:35)
    at <anonymous>
consoleError @ zone.js:522
handleUnhandledRejection @ zone.js:527
_loop_1 @ zone.js:562
drainMicroTaskQueue @ zone.js:566
Promise resolved (async)
scheduleQueueDrain @ zone.js:505
scheduleMicroTask @ zone.js:513
ZoneDelegate.scheduleTask @ zone.js:356
Zone.scheduleTask @ zone.js:196
Zone.scheduleMicroTask @ zone.js:207
scheduleResolveOrReject @ zone.js:711
ZoneAwarePromise.then @ zone.js:800
PlatformRef_._bootstrapModuleWithZone @ core.es5.js:4596
PlatformRef_.bootstrapModule @ core.es5.js:4581
(anonymous) @ ng2app.module.ts:140
__webpack_require__ @ bootstrap 2f644bad14cb0bb324ab:691
fn @ bootstrap 2f644bad14cb0bb324ab:110
(anonymous) @ app.js:116
__webpack_require__ @ bootstrap 2f644bad14cb0bb324ab:691
fn @ bootstrap 2f644bad14cb0bb324ab:110
(anonymous) @ util (ignored):1
__webpack_require__ @ bootstrap 2f644bad14cb0bb324ab:691
webpackJsonpCallback @ bootstrap 2f644bad14cb0bb324ab:23
(anonymous) @ app.bundle.js:1

解决方法

这似乎是调整@NgModule({providers:[]})和upgrade.bootstrap解决方案的问题.

在这里你需要$injector,但它在被请求时没有被注入.

在docs中它说你应该使用ngdobootstrap钩子.

export function userServiceFactory(i: any) {
  return i.get('UserService');
}

export const userServiceProvider = {
  provide: 'UserService',useFactory: userServiceFactory,deps: ['$injector']
};

import { browserModule } from '@angular/platform-browser';
import { UpgradeModule } from '@angular/upgrade/static';
import { platformbrowserDynamic } from '@angular/platform-browser-dynamic';
@NgModule({
  imports: [
    browserModule,providers: [
     userServiceProvider
  ]
}) 


export default class Ng2AppModule {

   constructor(private upgrade: UpgradeModule) { }

   ngdobootstrap() {
     this.upgrade.bootstrap(document.body,{ strictDi: true });
   }
}

platformbrowserDynamic().bootstrapModule(Ng2AppModule);

由安德鲁·卢林编辑为后代
不幸的是,即使这正是在角度文档中写的正是如此.这里的原始答案是:

import { forwardRef } from '@angular/core';

useFactory: (forwardRef(() => '$injector')i: any) => i.get('UserService')

而这似乎比这更接近答案.这也不起作用 – 但这似乎是因为TypeScript不认为语法是正确的.

更新:

我们对useFactory如此着迷,以至于我们没有看到修复只是将forwardRef添加到服务中.

@Injectable()
export class AnAngularservice{
  constructor(@Inject(forwardRef(() => 'UserService')) private userService: UserService
  ){}
}

angular – Webpack bootstrap-loader错误:无法解析’./bootstrap-styles’并且无法解析’./bootstrap-scripts’

angular – Webpack bootstrap-loader错误:无法解析’./bootstrap-styles’并且无法解析’./bootstrap-scripts’

我试图在 angular 2 project中使用 bootstrap-loader.Webpack编译输出错误:

ERROR in ./~/bootstrap-webpack/index.js
Module not found: Error: Can't resolve './bootstrap-styles' in 'd:\web\angular2-webpack-starter\node_modules\bootstrap-webpack'
 @ ./~/bootstrap-webpack/index.js 1:0-66
 @ ./src/vendor.browser.ts
 @ multi vendor

ERROR in ./~/bootstrap-webpack/index.js
Module not found: Error: Can't resolve './bootstrap-scripts' in 'd:\web\angular2-webpack-starter\node_modules\bootstrap-webpack'
 @ ./~/bootstrap-webpack/index.js 2:0-52
 @ ./src/vendor.browser.ts
 @ multi vendor

重现步骤:

>克隆https://github.com/AngularClass/angular2-webpack-starter
> npm安装
> npm install bootstrap-webpack –save
> npm install less-loader less –save-dev
> add line:require(“bootstrap-webpack”);到src / vendor.browser.ts
>从bootstrap-webpack文档中添加一些规则到config / webpack.common.js:
> npm开始

bootstrap-webpack documentation的规则:

// bootstrap-webpack has access to the jQuery object
{ test: /bootstrap\/js\//,loader: 'imports?jQuery=jquery' },// Needed for the css-loader when [bootstrap-webpack](https://github.com/bline/bootstrap-webpack)
// loads bootstrap's css.
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,loader: "url?limit=10000&mimetype=application/font-woff" },{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,loader: "url?limit=10000&mimetype=application/octet-stream" },{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,loader: "file" },{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,loader: "url?limit=10000&mimetype=image/svg+xml" }

解决方法

我得到它的工作,不得不安装几个加载器(bootstrap-webpack似乎并不依赖于它们),因为url-loader和文件加载器必须在这里安装确切的版本并且必须使用webpack 1(其中一个包)取决于它):

//packages.json
{
  "dependencies": {
    "bootstrap-webpack": "^0.0.5","jquery": "^3.1.1",},"main": "js/entry.js","devDependencies": {
    "babel-core": "^6.22.1","babel-loader": "^6.2.10","babel-preset-es2015": "^6.22.0","bootstrap": "^3.3.7","css-loader": "^0.26.1","exports-loader": "^0.6.3","extract-text-webpack-plugin": "^1.0.1","file-loader": "0.8.1","imports-loader": "^0.7.0","less": "^2.7.2","less-loader": "^2.2.3","style-loader": "^0.13.1","url-loader": "0.5.5","webpack": "1"
  }
}

// webpack.config.js
module: {
    loaders: [
        {test: /\.jsx?$/,loader: 'babel-loader',exclude: /(node_modules|bower_components)/,query: {presets: ['es2015']}},{test: /\.css$/,loader: 'css-loader'},{test: /\.(woff|woff2)$/,loader: 'url-loader?limit=10000'},{test: /\.ttf$/,loader: 'file-loader'},{test: /\.eot$/,{test: /\.svg$/,loader: 'file-loader'}
    ]
}

然后添加require(“bootstrap-webpack”);并运行webpack,不知何故,它的工作原理!

关于angularjs – 错误:无法解析’child_process’Angular-cli无法解析jstl的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于Angular 11:- 找不到模块:错误:无法解析'../../../../node_modules/@angular/forms/forms'、Angular AOT&Rollup – 无法解析’app.module.ngfactory’、Angular NgUpgrade将AngularJS服务注入Angular服务;获取:未处理的Promise拒绝:无法读取未定义的属性’get’;区:、angular – Webpack bootstrap-loader错误:无法解析’./bootstrap-styles’并且无法解析’./bootstrap-scripts’的相关知识,请在本站寻找。

本文标签: