javascript - 无法加载转译器

标签 javascript angularjs node.js

我有一个在 Node 上运行的 Angular 应用程序,最近我才开始遇到问题。我的转译器出现错误:请参阅图片。

Chrome Developer Image

所以应用程序正在运行,我正在尝试加载 mmmagic,以便我可以评估上传的文件。好吧,我不能因为另一个原因。但在此过程中我开始更新大部分 NPM 包。当我开始收到此错误时,我放弃了加载 mmmagic,并打算做其他事情。根据我上传的图像,我不明白它是如何不加载 typescript 的。我已经尝试了我能想到的一切,更新了大多数包,更改了 tsconfig.json、systemjs.config.js 中的值,重新加载了 node_modules...Typescript 在那里,但由于某种原因它没有加载它。

System.config({
transpiler: 'typescript.js',
typescriptOptions: {
    emitDecoratorMetadata: true,
    target: "ES5",
    module: "commonjs"},
map: {
    '@angular': 'node_modules/@angular',
    'rxjs'    : 'node_modules/rxjs',
},
paths: {
    'node_modules/@angular/*': 'node_modules/@angular/*/bundles'
},
meta: {
    '@angular/*': {'format': 'cjs'},
    'typescript': {
        "exports": "ts"
    }
},
packages: {
    'app'                              : {main: 'main', defaultExtension: 'ts'},
    'rxjs'                             : {main: 'Rx'},
    '@angular/core'                    : {main: 'core.umd.min.js'},
    '@angular/common'                  : {main: 'common.umd.min.js'},
    '@angular/compiler'                : {main: 'compiler.umd.min.js'},
    '@angular/router'                  : {main: 'router.umd.min.js'},
    '@angular/forms'                   : {main: 'forms.umd.min.js'},
    '@angular/http'                    : {main: 'http.umd.min.js'},
    '@angular/platform-browser'        : {main: 'platform-browser.umd.min.js'},
    '@angular/platform-browser-dynamic': {main: 'platform-browser-dynamic.umd.min.js'}
}

});

如果我可以上传任何可能有帮助的内容,请告诉我。我似乎遇到了这个障碍。

谢谢

<小时/>

更新

所以我仍在做一些研究,并且能够通过在 systemjs.config.js 中指定完整路径来解决最初的问题。

map: {
    '@angular': 'node_modules/@angular',
    'rxjs'    : 'node_modules/rxjs',
    'typescript': 'node_modules/typescript/lib/typescript.js'
},

所以现在我没有遇到任何不加载转换器的问题,但现在我收到了这个错误。

Error: typescript is not a valid transpiler plugin.

查看图片enter image description here

我现在不知道这是什么意思,几乎要背单词了......

谢谢

最佳答案

我不能让这个休息。所以这个问题的开始记录在这里

https://github.com/systemjs/systemjs/issues/1587

似乎转译器的默认加载器已更改。所以我遵循了上面线程中“guybedford”的建议。必须安装插件 typescript 并进行相应的配置。以下是更新后的 Systemjs.config 文件。

System.config({
transpiler: 'ts',
typescriptOptions: {
    emitDecoratorMetadata: true,
    experimentalDecorators: true,
    target: "ES5",
    module: "system"
    //module: "commonjs"
    },
map: {
    '@angular': 'node_modules/@angular',
    'rxjs'    : 'node_modules/rxjs',
    'typescript': 'node_modules/typescript/',
    'ts': 'node_modules/plugin-typescript/lib'
},
paths: {
    'node_modules/@angular/*': 'node_modules/@angular/*/bundles'
},
meta: {
    '@angular/*': {'format': 'cjs'},
    'node_modules/typescript/lib/typescript.js': {
        'exports': 'ts'
    }
},
packages: {
    'app'                              : {main: 'main', defaultExtension: 'ts'},
    'rxjs'                             : {main: 'Rx'},
    '@angular/core'                    : {main: 'bundles/core.umd.min.js'},
    '@angular/common'                  : {main: 'bundles/common.umd.min.js'},
    '@angular/compiler'                : {main: 'bundles/compiler.umd.min.js'},
    '@angular/router'                  : {main: 'bundles/router.umd.min.js'},
    '@angular/forms'                   : {main: 'bundles/forms.umd.min.js'},
    '@angular/http'                    : {main: 'bundles/http.umd.min.js'},
    '@angular/platform-browser'        : {main: 'bundles/platform-browser.umd.min.js'},
    '@angular/platform-browser-dynamic': {main: 'bundles/platform-browser-dynamic.umd.min.js'},
    'ts'                               : {main: 'plugin.js'},
    'typescript'                       : {main: 'lib/typescript.js'}
}

});

关于javascript - 无法加载转译器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43484507/

相关文章:

javascript - 如何使用Jquery对数组进行排序

javascript - Angular UI 路由器 : where should I be changing state? Controller ?服务?事件监听器?

angularjs - Angular 嵌套组件父级未定义

javascript - 使用pdf2json在azure函数中读取pdf

Node.js发送HTML文件等静态文件

javascript - 使用 ExtJS 创建动态网格

javascript - 如何使用类名更改多个文本输入的值

javascript - 使用angularJS在ng-bind中解析html

node.js:导出嵌套匿名异步函数中包含的变量

javascript - 链接ajax并按顺序执行。 Jquery 延迟