admin管理员组文章数量:1291117
I am learning TypeScript and today I installed SystemJS so that I could import some files. First I only imported the main file that needed being run i.e. app.js, in index.html
<script src="node_modules/systemjs/dist/system.js"></script>
<script>
System.import('app.js');
</script>
But I got this error: .png
So I turned my html code into this:
<script src="node_modules/systemjs/dist/system.js"></script>
<script>
System.config({
baseURL: '/',
packages: {
"/ts": {
defaultExtension: 'js'
}
}
});
System.import('app.js');
</script>
Now I am getting this error: .png
package.json:
{
"name": "ts",
"version": "1.0.0",
"description": "",
"main": "app.js",
"dependencies": {
"jquery": "^3.4.0",
"systemjs": "^3.1.2",
"typescript": "^3.4.2"
},
"devDependencies": {
"lite-server": "^2.4.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "lite-server"
},
"author": "",
"license": "ISC"
}
app.ts: console.log("Hello")
I am stuck at this point. Any help would be appreciated. Thanks in advance.
I am learning TypeScript and today I installed SystemJS so that I could import some files. First I only imported the main file that needed being run i.e. app.js, in index.html
<script src="node_modules/systemjs/dist/system.js"></script>
<script>
System.import('app.js');
</script>
But I got this error: https://i.sstatic/lz7Hm.png
So I turned my html code into this:
<script src="node_modules/systemjs/dist/system.js"></script>
<script>
System.config({
baseURL: '/',
packages: {
"/ts": {
defaultExtension: 'js'
}
}
});
System.import('app.js');
</script>
Now I am getting this error: https://i.sstatic/RS0k7.png
package.json:
{
"name": "ts",
"version": "1.0.0",
"description": "",
"main": "app.js",
"dependencies": {
"jquery": "^3.4.0",
"systemjs": "^3.1.2",
"typescript": "^3.4.2"
},
"devDependencies": {
"lite-server": "^2.4.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "lite-server"
},
"author": "",
"license": "ISC"
}
app.ts: console.log("Hello")
I am stuck at this point. Any help would be appreciated. Thanks in advance.
Share Improve this question edited Aug 25, 2019 at 19:40 Ian Kemp - SE killed by LLMs 29.9k21 gold badges124 silver badges162 bronze badges asked Apr 15, 2019 at 13:29 HowardHoward 1091 silver badge6 bronze badges 6-
Move the code from the second
<script>
tag inside the first one. – Roberto Zvjerković Commented Apr 15, 2019 at 13:35 - @ritaj The error seems to have vanished. But the console is empty i.e. app.js is not being loaded. – Howard Commented Apr 15, 2019 at 13:42
- Im facing the same problem – ktaro Commented Jun 28, 2019 at 16:25
- @Howard Following Maximilians' course on typescript? – Neeraj Sewani Commented Aug 25, 2019 at 18:14
- @neer17 yes. Unfortunately, I couldn't find the solution and had to skip the part – Howard Commented Aug 27, 2019 at 9:25
2 Answers
Reset to default 6I guess you would have upgraded to the latest system.js by mistake... SystemJS 2.0 does not support System.Config Refer to https://guybedford./systemjs-2.0
It is instead done using https://github./systemjs/systemjs/blob/2.0.0/docs/package-name-maps.md
If you managed to update the code by now, might as well post the updated sample here for use of everyone.
Locate system.js and put System.config()
inside it, this would fix the error.
<script src="node_modules/systemjs/dist/system.js">
System.config({
baseURL: "/",
packages: {
"/": {
defaultJSExtensions: true
}
}
})
System.import("app.js")</script>
<script>
本文标签: javascriptHow to fix 3939TypeError Systemconfig is not a function39Stack Overflow
版权声明:本文标题:javascript - How to fix ''TypeError: System.config is not a function' - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741525781a2383456.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论