-
-
Notifications
You must be signed in to change notification settings - Fork 535
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
"Cannot find module 'http'. (2307)" with "@types/node" under typescript@2.0.3 #216
Comments
I have the same problem. It seems I can workaround it using the following directive at the top of my file (which is located in
Running EDIT: Here's another workaround, which seems a little better: #179 (comment)
|
Hi, I had the same issue with mocha on #246 The problem is that module http is ambient declared by node declaration file. What ts-node do is
My first solution was to import module mocha import * as mocha from 'mocha'; To have all mocha declarations available but I did not know that we could declare an ambient module via /// <reference types="mocha" /> Declaring mocha as ambient in tsconfig.json did not work for me {
"compilerOptions": {
"types": ["mocha"]
}
} I don't know why exactly because it should be equivalent... Again I faced a new issue not declaring these references outside of my tests in a separated file with only one spec file. It works with two spec files ??? I think this is most a mocha --compilers issue. I've created a repo here explaining the solution. |
My fix for windows, after trying most suggestions, was to remove
in combination with adding this to my src/typings.d.ts
Tsnode 1.7.0 |
Fixes the "npm run test" commad error, based on a comment from: TypeStrong/ts-node#216 (comment)
@MrCrimp although that also solved it for me, the bug remains. As per the documentation of TypeScript:
Be aware that using this solutions, you may introduce some side effects / unexpected behavior:
|
Fixes Windows builds using ts-node module, to resolve the following issue: TypeStrong/ts-node#216
A combination of 'typeRoots' and "compilerOptions": {
"typeRoots": [
"node_modules/@types"
],
"types": [
"mocha"
]
} (On OS X, neither of these was needed, and I'm sure the same is true for Linux.) |
We are facing what seems to be a related issue. In our scenario, we have multiple And the error can be seen here: However, what we're seeing is that it works fine on Windows, and we only get this error on Linux. |
This should be resolved with |
I am getting this with |
I am also getting this on |
I also have this problem on MacOS. I created a minimal test project. Running yarn install
gulp results in the following output:
|
@jochenseeber Your issue is caused by a lack of |
I'm also seeing this on OS X with ts-node@3.2.0, typescript@2.4.1 and the config below.
{
"compilerOptions": {
"charset": "utf-8",
"declaration": true,
"downlevelIteration": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"jsx": "react",
"lib": [
"dom",
"es2016",
"es2017.object"
],
"module": "commonjs",
"newLine": "LF",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "./dist/",
"pretty": true,
"rootDir": ".",
"sourceMap": true,
"strictNullChecks": true,
"target": "es5"
}
} |
I have the same problem on linux,
|
@danielpa9708 add {
"typeRoots": [
"./node_modules/@types"
],
"types": ["node"]
} In your |
The solution to this problem is simple than you think : 💯 🥇 |
TypeScript Version:
2.0.3
Code
Expected behavior:
should import http as well
Actual behavior:
TS2307 error
Another STRANGE behavior
if I add another @types into t.ts, it will work without any problem.
very interesting, what's wrong with me?
The text was updated successfully, but these errors were encountered: