Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@types/requirejs Variable 'require' must be of type 'NodeRequire' #15851

Open
3 of 4 tasks
michelle-burton opened this issue Apr 13, 2017 · 5 comments
Open
3 of 4 tasks

Comments

@michelle-burton
Copy link

michelle-burton commented Apr 13, 2017

  • I tried using the @types/requirejs package and had problems.
    Error from console:
node_modules/@types/requirejs/index.d.ts
(416,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'require' must be of type 'NodeRequire', but here has type 'Require'.

typescript error -

in @types/requirejs/index.d.ts
ln416 declare var require: Require;

And in @types/node/index.d.ts
ln73 declare var require: NodeRequire;

Thanks

Michelle

@reiskoch
Copy link

reiskoch commented Apr 27, 2017

Same Problem here with error message with different order (using webpack1 and ts-loader)

node_modules/@types/webpack-env/index.d.ts
Subsequent variable declarations must have the same type. Variable 'require' must be of type 'Require', but here has type 'NodeRequire'.

And node_modules/@types/node/index.d.ts
error TS2403: Subsequent variable declarations must have the same type. Variable 'require' must be of type 'Require', but here has type 'NodeRequire'.

But i also get

error TS2306: File '/node_modules/@types/requirejs/index.d.ts' is not a module.

UPDATE: if i use at-loader i get the same error as cyandream:
ERROR in [at-loader] node_modules/@types/requirejs/index.d.ts:416:13 Subsequent variable declarations must have the same type. Variable 'require' must be of type 'NodeRequire', but here has type 'Require'.

but also
ERROR in [at-loader] src/index.tsx:17:28 File 'node_modules/@types/requirejs/index.d.ts' is not a module.

@e-cloud
Copy link
Contributor

e-cloud commented May 26, 2017

see a may-be solution here https://medium.com/@mindginative/typescript-its-magic-number-ts2403-ef76202185c9

@kumaresan-subramani
Copy link

kumaresan-subramani commented Dec 24, 2018

I am also facing same problem. this breaks my entire application

[11:20:44] D:/workspace/components/ej2-button-components/node_modules/@types/requirejs/index.d.ts(421)
Subsequent variable declarations must have the same type. Variable 'require' must be of type 'NodeRequire', but here has type 'Require'.
Rendering [========================================] 100%
[11:20:46] Finished 'typedoc' after 12 s
[11:20:46] Finished 'execute-generator' after 12 s
[11:20:46] Starting 'scripts'...
[11:20:46] Starting 'scripts-gen'...
D:/workspace/components/ej2-button-components/node_modules/@types/requirejs/index.d.ts(422,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'require' must be of type 'NodeRequire', but here has type 'Require'.
[11:20:58] 'scripts-gen' errored after 12 s
[11:20:58] TypeScript error: D:/workspace/components/ej2-button-components/node_modules/@types/requirejs/index.d.ts(422,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'require' must be of type 'NodeRequire', but here has type 'Require'.
at Object.getError (D:\workspace\components\ej2-button-components\node_modules\gulp-typescript\release\utils.js:53:15)
at Output.getError (D:\workspace\components\ej2-button-components\node_modules\gulp-typescript\release\output.js:224:22)
at Output.diagnostic (D:\workspace\components\ej2-button-components\node_modules\gulp-typescript\release\output.js:227:25)
at ProjectCompiler.inputDone (D:\workspace\components\ej2-button-components\node_modules\gulp-typescript\release\compiler.js:69:33)
at CompileStream.end (D:\workspace\components\ej2-button-components\node_modules\gulp-typescript\release\main.js:62:31)
at DestroyableTransform.onend (D:\workspace\components\ej2-button-components\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:523:10)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at DestroyableTransform.emit (events.js:208:7)
at D:\workspace\components\ej2-button-components\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:965:16
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
[11:20:58] 'build' errored after 24 s
[11:20:58] TypeScript error in plugin 'run-sequence(scripts-gen)'

Please provide any workaround for this

@kumaresan-subramani
Copy link

same problem #31628

@abhinavsingh
Copy link

Anyone visiting this after years :) Here is what we observed.

  1. We are building a project for browser
  2. But also using mocha without testing in browser
  3. This required us to install ts-node and amd-loader
  4. Unfortunately, installing these deps started resulting in built errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants