2016-11-08 4 views
1

Ich habe https://github.com/FountainJS/generator-fountain-webapp verwendet, um ein neues Projekt mit Hilfe von React & Typescript einzurichten. Ich bin ziemlich zufrieden damit, dass JS Knoten für ein laufendes Projekt verwendet hat, aber nicht mit TS vertraut ist, wo das Problem zu liegen scheint.TS kann keine Module finden

Ich habe den Generator mit der folgenden Umgebung ausgeführt: Typoskript, reagieren, Webpack w/NPM, Schluck.

Wenn ich gulp serve laufen lasse ich die Ausgabe unten. Ich bin ziemlich verwirrt, warum es die Dateien nicht finden kann - sie sind alle in meinem Dateisystem vorhanden. Ich habe in anderen Fragen geschaut und habe nichts gefunden, das mein Problem behebt

[23:04:52] Loading /Users/omelvin/github_projects/kaizen/gulp_tasks/browsersync.js 
[23:04:53] Loading /Users/omelvin/github_projects/kaizen/gulp_tasks/karma.js 
[23:04:54] Loading /Users/omelvin/github_projects/kaizen/gulp_tasks/misc.js 
[23:04:54] Loading /Users/omelvin/github_projects/kaizen/gulp_tasks/webpack.js 
[23:04:54] Using gulpfile ~/github_projects/kaizen/gulpfile.js 
[23:04:54] Starting 'serve'... 
[23:04:54] Starting 'webpack:watch'... 
ts-loader: Using [email protected] and /Users/omelvin/github_projects/kaizen/tsconfig.json 
[23:05:01] Time: 6436ms 
     Asset  Size Chunks  Chunk Names 
    index.js 1.11 MB  0  main 
index.js.map 1.32 MB  0  main 

ERROR in ./src/index.tsx 
(5,24): error TS2307: Cannot find module 'react'. 

ERROR in ./src/index.tsx 
(6,27): error TS2307: Cannot find module 'react-dom'. 

ERROR in ./src/index.tsx 
(7,45): error TS2307: Cannot find module 'react-router'. 

ERROR in ./src/index.tsx 
(1,1): error TS6053: File '/Users/omelvin/github_projects/kaizen/typings/index.d.ts' not found. 

ERROR in ./src/app/title.tsx 
(3,24): error TS2307: Cannot find module 'react'. 

ERROR in ./src/app/title.tsx 
(1,1): error TS6053: File '/Users/omelvin/github_projects/kaizen/typings/index.d.ts' not found. 

ERROR in ./src/app/techs/techs.tsx 
(3,24): error TS2307: Cannot find module 'react'. 

ERROR in ./src/app/techs/techs.tsx 
(4,24): error TS2307: Cannot find module 'axios'. 

ERROR in ./src/app/techs/techs.tsx 
(33,10): error TS2339: Property 'state' does not exist on type 'Techs'. 

ERROR in ./src/app/techs/techs.tsx 
(39,24): error TS2503: Cannot find namespace 'Axios'. 

ERROR in ./src/app/techs/techs.tsx 
(40,14): error TS2339: Property 'setState' does not exist on type 'Techs'. 

ERROR in ./src/app/techs/techs.tsx 
(51,17): error TS2339: Property 'state' does not exist on type 'Techs'. 

ERROR in ./src/app/techs/techs.tsx 
(1,1): error TS6053: File '/Users/omelvin/github_projects/kaizen/typings/index.d.ts' not found. 

ERROR in ./src/app/techs/tech.tsx 
(3,24): error TS2307: Cannot find module 'react'. 

ERROR in ./src/app/techs/tech.tsx 
(50,44): error TS2339: Property 'props' does not exist on type 'TechComponent'. 

ERROR in ./src/app/techs/tech.tsx 
(52,17): error TS2339: Property 'props' does not exist on type 'TechComponent'. 

ERROR in ./src/app/techs/tech.tsx 
(54,18): error TS2339: Property 'props' does not exist on type 'TechComponent'. 

ERROR in ./src/app/techs/tech.tsx 
(55,18): error TS2339: Property 'props' does not exist on type 'TechComponent'. 

ERROR in ./src/app/techs/tech.tsx 
(1,1): error TS6053: File '/Users/omelvin/github_projects/kaizen/typings/index.d.ts' not found. 

ERROR in ./src/app/main.tsx 
(3,24): error TS2307: Cannot find module 'react'. 

ERROR in ./src/app/main.tsx 
(1,1): error TS6053: File '/Users/omelvin/github_projects/kaizen/typings/index.d.ts' not found. 

ERROR in ./src/app/header.tsx 
(3,24): error TS2307: Cannot find module 'react'. 

ERROR in ./src/app/header.tsx 
(1,1): error TS6053: File '/Users/omelvin/github_projects/kaizen/typings/index.d.ts' not found. 

ERROR in ./src/app/footer.tsx 
(3,24): error TS2307: Cannot find module 'react'. 

ERROR in ./src/app/footer.tsx 
(1,1): error TS6053: File '/Users/omelvin/github_projects/kaizen/typings/index.d.ts' not found. 

ERROR in /Users/omelvin/github_projects/kaizen/src/app/footer.spec.tsx 
(4,24): error TS2307: Cannot find module 'react'. 

ERROR in /Users/omelvin/github_projects/kaizen/src/app/footer.spec.tsx 
(5,27): error TS2307: Cannot find module 'react-dom'. 

ERROR in /Users/omelvin/github_projects/kaizen/src/app/footer.spec.tsx 
(6,28): error TS2307: Cannot find module 'react-addons-test-utils'. 

ERROR in /Users/omelvin/github_projects/kaizen/src/app/footer.spec.tsx 
(10,1): error TS2304: Cannot find name 'describe'. 

ERROR in /Users/omelvin/github_projects/kaizen/src/app/footer.spec.tsx 
(11,3): error TS2304: Cannot find name 'it'. 

ERROR in /Users/omelvin/github_projects/kaizen/src/app/footer.spec.tsx 
(14,5): error TS2304: Cannot find name 'expect'. 

ERROR in /Users/omelvin/github_projects/kaizen/src/app/footer.spec.tsx 
(1,1): error TS6053: File '/Users/omelvin/github_projects/kaizen/typings/index.d.ts' not found. 
Child html-webpack-plugin for "index.html": 
     Asset Size Chunks  Chunk Names 
    index.html 564 kB  0 
[23:05:01] Finished 'webpack:watch' after 6.45 s 
[23:05:01] Starting 'watch'... 
[23:05:01] Finished 'watch' after 54 ms 
[23:05:01] Starting 'browsersync'... 
[23:05:01] Finished 'browsersync' after 78 ms 
[23:05:01] Finished 'serve' after 6.58 s 
[BS] [BrowserSync SPA] Running... 
[BS] Access URLs: 
-------------------------------------- 
     Local: http://localhost:3000 
    External: http://10.193.122.24:3000 
-------------------------------------- 
      UI: http://localhost:3001 
UI External: http://10.193.122.24:3001 
-------------------------------------- 
[BS] Serving files from: .tmp 
[BS] Serving files from: src 
ts-loader: Using [email protected] and /Users/omelvin/github_projects/kaizen/tsconfig.json 
webpack built 5ccca2fe23cfa5a1a610 in 5073ms 

Antwort

4

Typoskript auf Definitionsdateien beruhen, die die Typen, Schnittstellen etc. für Bibliotheken definieren. Ich bin nicht vertraut mit FountainJS, aber ich schätze, es ist schlau genug, um eine typings.json Datei in Ihrem Arbeitsbereich zu erstellen. Wenn dies der Fall ist, müssen Sie nur typings (npm install typings --global) installieren und dann die Definitionen installieren, indem Sie typings install ausführen.

Wenn sie typings.json nicht enthielten (obwohl ich mir nicht vorstellen kann, dass sie das nicht tun würden), folgen Sie den Anweisungen auf ihrer README, um Definitionen für die Abhängigkeiten zu suchen und zu installieren.

ich in der Regel die folgenden Zeilen package.json so hinzufügen, dass die Typisierungen automatisch jederzeit installiert werden Sie npm install

"scripts": { "postinstall": "npm run typings", "typings": "typings install", }

laufen Wenn Sie nicht vertraut mit Typoskript sind, empfehle ich gehen durch ihre grundlegenden Tutorial um loszulegen: https://www.typescriptlang.org/docs/tutorial.html.

+0

Ich bin ein bisschen peinlich, aber danke. Ich habe ein paar Tage zuvor daran gearbeitet und bin dann wieder dazu gekommen, also nicht 100%, aber ich schwöre, ich habe das getan. Ich hatte ein paar Probleme mit Npm, also musste ich das neu installieren und jetzt machte es das wieder. – Vanquish46

Verwandte Themen