简体   繁体   English

IntelliJ(或Webstorm)无法识别从systemJs导入的内容

[英]IntelliJ (or Webstorm) does not recognise imports from systemJs

I do not understand how I can make IntelliJ understand that my library was mapped with SystemJS. 我不明白如何使IntelliJ了解我的库是使用SystemJS映射的。 So I get a red wavy line under my import, like the following image illustrates: 因此,我的导入下出现一条红色的波浪线,如下图所示:

情报错误

However, the module is loaded correctly and I can use it, ie the website is working. 但是,该模块已正确加载,我可以使用它,即网站正在运行。 The @angular/core seems to be recognised. @angular/core似乎可以识别。 I use the following mapping in system.config.js : 我在system.config.js使用以下映射:

var map = {
    'app':                        '/ng2experiments/app', // 'dist',
    '@angular':                   '/ng2experiments/node_modules/@angular',
    'angular2-in-memory-web-api': '/ng2experiments/node_modules/angular2-in-memory-web-api',
    'rxjs':                       '/ng2experiments/node_modules/rxjs',
    'notifications':              '/ng2experiments/node_modules/angular2-notifications'
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
    'app':                        { main: 'main.js',  defaultExtension: 'js' },
    'rxjs':                       { defaultExtension: 'js' },
    'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
    'notifications':              { main: 'components.js', defaultExtension: 'js' }
};

Why is it @angular/core gets recognised but not notifications ? 为什么@angular/core被识别但没有notifications

I found the answer during writing the question. 我在写问题时找到了答案。 I'll post it anyways as Q&A because other people might find it useful. 我还是以问答形式发布它,因为其他人可能会发现它很有用。

It's because @angular/core is the actual folder name, while notifications is not (it's called angular2-notifications). 这是因为@angular/core是实际的文件夹名称,而notifications不是(称为angular2-notifications)。 IntelliJ / Webstorm knows nothing about SystemJs. IntelliJ / Webstorm对SystemJ一无所知。 An easy way to solve this is to change the mapping in SystemJs to use the same name as your folder. 解决此问题的一种简单方法是将SystemJs中的映射更改为使用与文件夹相同的名称。 In this case: 在这种情况下:

var map = {
    'app':                        '/ng2experiments/app', // 'dist',
    '@angular':                   '/ng2experiments/node_modules/@angular',
    'angular2-in-memory-web-api': '/ng2experiments/node_modules/angular2-in-memory-web-api',
    'rxjs':                       '/ng2experiments/node_modules/rxjs',
    'angular2-notifications':     '/ng2experiments/node_modules/angular2-notifications'
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
    'app':                        { main: 'main.js',  defaultExtension: 'js' },
    'rxjs':                       { defaultExtension: 'js' },
    'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
    'angular2-notifications':     { main: 'components.js', defaultExtension: 'js' }
};

IntelliJ / Webstorm should check out of the box for all the folder names, so it then recognises the module: IntelliJ / Webstorm应该选中所有文件夹名称的框,以便随后识别该模块:

IntelliJ解决了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM