我一直緊跟着步驟這個簡單的教程一步,但我得到這個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