我一直紧跟着步骤这个简单的教程一步,但我得到这个404错误 enter link description here打字稿与systemjs配置错误
我敢肯定,我已经安装了打字稿本地
npm install typescript --save
(打字稿在node_modules文件夹存在)
这是精简版服务器的输出
17.05.18 09:14:25 200 GET /index.html
17.05.18 09:14:25 200 GET /node_modules/systemjs/dist/system.js
17.05.18 09:14:25 200 GET /node_modules/systemjs/dist/system.js.map
17.05.18 09:14:25 200 GET /node_modules/typescript/lib/typescript.js
17.05.18 09:14:25 200 GET /src/main.ts
17.05.18 09:14:25 404 GET /typescript
,并在浏览器控制台
[object Error]{description: "Fetch error...", message: "Fetch error...", name: "Error", originalErr: Error {...}, stack: "Error: Fetc..."}
Instantiating http://localhost:3000/typescript
Loading typescript
Unable to load transpiler to transpile http://localhost:3000/src/main.ts
Instantiating http://localhost:3000/src/main.ts
我怎样才能进一步调查?
项目结构:
.
├── index.html
├── package.json
└── src
├── main.ts
└── person.ts
的index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>SystemJS</title>
<script src="node_modules/systemjs/dist/system.js"></script>
<script src="node_modules/typescript/lib/typescript.js"></script>
<script>
System.config({
transpiler: 'typescript',
packages : {
src: {
defaultExtension: 'ts'
}
}
});
System
.import('src/main')
.then(null, console.error.bind(console));
</script>
</head>
<body>
</body>
</html>
main.ts
import { Person } from './person';
let person = new Person();
console.log(person.name);
person.ts
export class Person {
public name: string = 'xxxxxx';
}
你能在控制台中得到的错误中发布完整的消息吗? – toskv
请提供源代码,很难说没有看到您的代码的东西。 –
提供的源代码 – alex