gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 13:45:42 28 4
gpt4 key购买 nike

我无法让 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 标准版。

谢谢罗宾

最佳答案

尝试在这里使用 map 配置而不是本地包 -

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

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

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

关于systemjs:将其他所有内容映射到 node_modules,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36360753/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com