nest.jsとtypescriptを学習しようと思い、nestの公式サイトをみてfirst stepにあるプロジェクトの生成と実行をやろうとしていますが、typescript関連のエラーになってしまいます。
typescriptは初心者ですが、mochaとjestのtype定義の適用先でコンパイラが混乱しているような気がします。
どのようにすれば解決できるのでしょうか?
実行したステップは以下のとおりです。
sh
1npm i -g @nestjs/cli 2nest new nest-lesson # npmを選択 → プロジェクトが生成される 3cd nest-lesson 4npm run start # ここでエラー
表示されるエラーは以下のとおりです。
sh
1 2../../../node_modules/@types/mocha/index.d.ts:36:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'describe' must be of type 'Describe', but here has type 'IContextDefinition'. 3 436 declare var describe: Mocha.IContextDefinition; 5 ~~~~~~~~ 6 7 node_modules/@types/jest/index.d.ts:38:13 8 38 declare var describe: jest.Describe; 9 ~~~~~~~~ 10 'describe' was also declared here. 11../../../node_modules/@types/mocha/index.d.ts:37:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'xdescribe' must be of type 'Describe', but here has type 'IContextDefinition'. 12 1337 declare var xdescribe: Mocha.IContextDefinition; 14 ~~~~~~~~~ 15 16 node_modules/@types/jest/index.d.ts:40:13 17 40 declare var xdescribe: jest.Describe; 18 ~~~~~~~~~ 19 'xdescribe' was also declared here. 20../../../node_modules/@types/mocha/index.d.ts:42:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'it' must be of type 'It', but here has type 'ITestDefinition'. 21 2242 declare var it: Mocha.ITestDefinition; 23 ~~ 24 25 node_modules/@types/jest/index.d.ts:41:13 26 41 declare var it: jest.It; 27 ~~ 28 'it' was also declared here. 29../../../node_modules/@types/mocha/index.d.ts:43:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'xit' must be of type 'It', but here has type 'ITestDefinition'. 30 3143 declare var xit: Mocha.ITestDefinition; 32 ~~~ 33 34 node_modules/@types/jest/index.d.ts:43:13 35 43 declare var xit: jest.It; 36 ~~~ 37 'xit' was also declared here. 38../../../node_modules/@types/mocha/index.d.ts:45:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'test' must be of type 'It', but here has type 'ITestDefinition'. 39 4045 declare var test: Mocha.ITestDefinition; 41 ~~~~ 42 43 node_modules/@types/jest/index.d.ts:44:13 44 44 declare var test: jest.It; 45 ~~~~ 46 'test' was also declared here. 47../../../node_modules/@types/mocha/index.d.ts:63:18 - error TS2300: Duplicate identifier 'beforeEach'. 48 4963 declare function beforeEach(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void; 50 ~~~~~~~~~~ 51 52 node_modules/@types/jest/index.d.ts:35:13 53 35 declare var beforeEach: jest.Lifecycle; 54 ~~~~~~~~~~ 55 'beforeEach' was also declared here. 56../../../node_modules/@types/mocha/index.d.ts:64:18 - error TS2300: Duplicate identifier 'beforeEach'. 57 5864 declare function beforeEach(description: string, callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void; 59 ~~~~~~~~~~ 60 61 node_modules/@types/jest/index.d.ts:35:13 62 35 declare var beforeEach: jest.Lifecycle; 63 ~~~~~~~~~~ 64 'beforeEach' was also declared here. 65../../../node_modules/@types/mocha/index.d.ts:65:18 - error TS2300: Duplicate identifier 'afterEach'. 66 6765 declare function afterEach(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void; 68 ~~~~~~~~~ 69 70 node_modules/@types/jest/index.d.ts:37:13 71 37 declare var afterEach: jest.Lifecycle; 72 ~~~~~~~~~ 73 'afterEach' was also declared here. 74../../../node_modules/@types/mocha/index.d.ts:66:18 - error TS2300: Duplicate identifier 'afterEach'. 75 7666 declare function afterEach(description: string, callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void; 77 ~~~~~~~~~ 78 79 node_modules/@types/jest/index.d.ts:37:13 80 37 declare var afterEach: jest.Lifecycle; 81 ~~~~~~~~~ 82 'afterEach' was also declared here. 83node_modules/@types/jest/index.d.ts:35:13 - error TS2300: Duplicate identifier 'beforeEach'. 84 8535 declare var beforeEach: jest.Lifecycle; 86 ~~~~~~~~~~ 87 88 ../../../node_modules/@types/mocha/index.d.ts:63:18 89 63 declare function beforeEach(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void; 90 ~~~~~~~~~~ 91 'beforeEach' was also declared here. 92 ../../../node_modules/@types/mocha/index.d.ts:64:18 93 64 declare function beforeEach(description: string, callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void; 94 ~~~~~~~~~~ 95 and here. 96node_modules/@types/jest/index.d.ts:37:13 - error TS2300: Duplicate identifier 'afterEach'. 97 9837 declare var afterEach: jest.Lifecycle; 99 ~~~~~~~~~ 100 101 ../../../node_modules/@types/mocha/index.d.ts:65:18 102 65 declare function afterEach(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void; 103 ~~~~~~~~~ 104 'afterEach' was also declared here. 105 ../../../node_modules/@types/mocha/index.d.ts:66:18 106 66 declare function afterEach(description: string, callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void; 107 ~~~~~~~~~ 108 and here. 109 110Found 11 error(s). 111
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/01/23 23:55