我正在使用traceur和es6加载器,但是我改为systemjs,当我尝试使用System.paths [' jquery']时,我收到了消息:
错误:无法直接设置SystemJS.paths [" jquery"]。使用SystemJS.config({路径:{" jquery":...}})而不是
所以我改为:
System.config({
paths: {
"jquery": "./node_modules/jquery/dist/jquery.js"
}
});
System.import('jquery');
System.import('src/app.js');
显示此错误:
system.js:4 Uncaught (in promise) Error: Fetch error: 404 Not Found
system.js:4 Uncaught (in promise) Error: Unable to dynamically transpile ES module
A loader plugin needs to be configured via `SystemJS.config({ transpiler: 'transpiler-module' })`.
我试过了,但没有工作:
System.config({
transpiler: "babel",
map: {
"babel": "./node_modules/babel-core/lib/api/browser.js",
"jquery": "./node_modules/jquery/dist/jquery.js"
}
})
错误
system.js:4 Uncaught (in promise) Error: Fetch error: 404 Not Found
Instantiating localhost:3000/node_modules/babel-core/lib/api/node
Loading localhost:3000/node_modules/babel-core/lib/api/browser.js
Loading babel
Unable to load transpiler to transpile localhost:3000/src/app.js
答案 0 :(得分:0)
我认为您需要告知systemjs应该将jquery添加为全局脚本,以便它不会尝试对其进行转换。请尝试以下方法:
System.config({
paths: {
"jquery": "./node_modules/jquery/dist/jquery.js"
},
meta: {
"jquery": { "format": "global" }
}
});