systemjs:将其他所有内容映射到 node_modules

systemjs: mapping everything else to node_modules

我无法让 systemjs 工作,所以它解析了节点模块。

我的 index.html 中有以下内容:

<script src="./system.config.js"></script>
<script>
    System.import('blast/test')
            .then(null, console.error.bind(console));
</script>

这是我的配置:

System.config({
    baseUrl: '/',
    packages: {
        'app': {
            defaultExtension: 'js',
        }
    },

    packageConfigPaths: ['./node_modules/*/package.json'],

    paths: {
        'blast/*': 'app/*'
    }
});

目前为止一切正常。但是,我还希望能够解析像 lodash 这样的节点模块。所以我为此设置了路径:

paths: {
    'blast/*': 'app/*'
    '*': './node_modules/*'
}

现在我可以正常导入 lodash,但是在导入 blast/test 时出现错误 /app/test 404 (not found)。看来,包配置不再使用了,这个 .js 没有附加。任何人有任何提示如何解决这个问题?我正在使用 SystemJs 0.19.25 标准版。

谢谢,罗宾

尝试在此处使用地图配置而不是本地包 -

System.config({
  map: {
    blast: './app'
  }
});

./ 是区分 URL space 和成为 node_modules/app 路径所必需的(可能是您在这里开始使用路径的原因?)

还建议使用 baseURL: 'node_modules' 而不是通配符路径条目(它们几乎是同一回事)。