"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": true,
"preserveConstEnums": true,
"outDir": "dist"
"include": [
"src/**/*"
console.log("test");
package.json
"name": "agent",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"start": "tsc && node dist/index.js",
"dev": "nodemon --watch 'src/**/*.ts' -e ts,tsx --exec 'ts-node' ./src/index.ts",
"debug": "nodemon --inspect --watch 'src/**/*' -e ts,tsx --exec 'ts-node' ./src/index.ts"
"dependencies": {
"@types/koa-router": "^7.0.32",
"koa": "^2.5.3",
"koa-router": "^7.4.0",
"nodemon": "^1.18.4",
"pg": "^7.5.0"
"devDependencies": {
"@types/koa": "^2.0.46",
"@types/pg": "^7.4.11",
"ts-node": "^7.0.1"
alextes, mbujold, hwanpenn, vadim-96, DPANET, matthias-ccri, brent-williams, htbkoo, aliabbas299792, kopkaa, and 6 more reacted with thumbs up emoji
onny reacted with eyes emoji
All reactions
whyboris, brightsparc, KxllSwxtch, ceoshikhar, and whenubelieve reacted with thumbs up emoji
wahur666, Oatelaus, misabiko, fr0, rexwhitten, Nufflee, IonelLupu, tuckwat, basickarl, angelch94, and 89 more reacted with thumbs down emoji
All reactions
I have this issue with typescript installed globally.
Here is the error:
Error: Cannot find module 'typescript'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.resolve (internal/modules/cjs/helpers.js:30:19)
at Object.register (C:\Users\marcb\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:208:28)
at Object. (C:\Users\marcb\AppData\Roaming\npm\node_modules\ts-node\src\bin.ts:108:17)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vipor-rest@0.1.0 dev: ts-node ./src/server.ts
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vipor-rest@0.1.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\marcb\AppData\Roaming\npm-cache_logs\2019-01-23T10_03_59_349Z-debug.log
Happens with the following packages:
ts-node@8.0.1
typescript@3.2.4
winnerwinnerchickdinner, martin-pabst, i474232898, eker247, EsterRibeiro, farrismelk, harshakns, Igur007, caph1993, amoretspero, and 15 more reacted with thumbs up emoji
Homsi959 reacted with thumbs down emoji
Nandan-Wewhare, sushiljainam-gt, and jeremythille reacted with hooray emoji
EsterRibeiro, jap-cs, and aadekoyaheurx reacted with heart emoji
All reactions
mburst, mdunaev, bastibense, wlodpawlowski, sidelong44, otokunaga2, subnomo, mkonars, KoStard, Sceptwo, and 47 more reacted with thumbs up emoji
ng-model, imans777, Sceptwo, amandabeiner, alon6699, pizzaminded, stevemu, NicoleAsqui, DandelionLove, sianliu, and elenaraujo reacted with hooray emoji
josingbo, wlodpawlowski, sidelong44, otokunaga2, amandabeiner, gabrielkunkel, pavel-main, alon6699, pizzaminded, scarktt, and 6 more reacted with heart emoji
pizzaminded, sianliu, and elenaraujo reacted with rocket emoji
All reactions
dance2die, subnomo, vadim-96, ORESoftware, inqb, codler, tsibley, felskov, adamgen, megahertz, and 21 more reacted with thumbs up emoji
ORESoftware and tomek1149 reacted with hooray emoji
ORESoftware, adamgen, tomek1149, and pavel-main reacted with rocket emoji
All reactions
@Redfish52 There's a 👍 button if you just want to chime in and aren't contributing to the issue.
For anyone else, I'd like to know if a flag is adequate enough for now.
Tayeb-Ali, Rishabh2325, twiggler, CCBet, WasimM3, ParagMeshram, cyberguroo, and jobwat reacted with thumbs up emoji
cyberguroo reacted with hooray emoji
cyberguroo and jobwat reacted with heart emoji
cyberguroo reacted with rocket emoji
All reactions
I have stumbled across this same issue just now.
"ts-loader": "^6.0.3",
"ts-node": "^8.3.0",
In ts file:
import ts from 'typescript';
tsconfig:
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"module": "ES6",
"target": "es6",
"jsx": "react"
If I change module to
"module": "commonjs"
it is able to find typescript. But with "ES6" option it magically loses this ability
error TS2307: Cannot find module 'typescript'.
dphochman, OrkhanAlikhanov, tomek1149, dipbd1, Brijeshlakkad, ubershmekel, nullromo, and sunshanpeng reacted with thumbs up emoji
vuki656 and sordado1 reacted with thumbs down emoji
OrkhanAlikhanov reacted with heart emoji
All reactions
I tried to reinstall the typescript
globally, and it works!
yarn global add typescript
npm i -g typescript
Try one way, and if it still don't work, then try the other way.
This did the trick for me.
For me just running the below command is not enough (though a valid first step):
npm install -g typescript
The following command is what you need (I think deleting node_modules works too but the below command is quicker).
npm link typescript
lamas250, erkinsergey, danielmayor, Nishi05, ferngus, lukaszbudnik, 0xtaosu, and tomonari-t reacted with thumbs up emoji
lamas250, erkinsergey, Nishi05, and 0xtaosu reacted with hooray emoji
matinhu, apustula, innapospiech, lfelguetac, Nazaroni, sunchenlong111, bastare, ToddEmonster, babajidemm, lamas250, and 4 more reacted with heart emoji
lamas250, rmsys, and 0xtaosu reacted with rocket emoji
All reactions
This did the trick for me.
For me just running the below command is not enough (though a valid first step):
npm install -g typescript
The following command is what you need (I think deleting node_modules works too but the below command is quicker).
npm link typescript
i have no idea why this occurred, but the command npm link typescript
saved my day;
thank you!
You should also be able to do a normal `npm install typescript`.
Typically, folks in the npm ecosystem will recommend installing
dependencies locally per-project, tracking version numbers in
package.json. (that's what the above command does)
This allows projects to function in isolation without potentially being
broken by a different globally-installed version number.
`npm link typescript` creates a symlink from your local project pointing at
the globally-installed version of typescript. So it's as if your globally
installed typescript was also installed locally.
`npm install typescript`, on the other hand, will install locally and track
the version number in your `package.json`. This means others can quickly
`npm install` and automatically get the same local environment as you,
which simplifies on-boarding and makes everything more predictable and
obvious.
On Tue, Jul 7, 2020, 4:30 PM MatinhoGlobal ***@***.***> wrote:
<
https://stackoverflow.com/questions/44611526/how-to-fix-cannot-find-module-typescript-in-angular-4>
did the trick for me.
For me just running the below command is not enough (though a valid first
step):
npm install -g typescript
The following command is what you need (I think deleting node_modules
works too but the below command is quicker).
npm link typescript
i have no idea why this occurred, but the command npm link typescript
saved my day;
thank you!
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<
#707 (comment)>,
or unsubscribe
<
https://github.com/notifications/unsubscribe-auth/AAC35OEZK3YLA4HYER6SDNDR2OAXZANCNFSM4F3H4SSA>
Once in a while, I'm in a stripped-down environment where I'd like to run ts-node
via npx
without permanently installing anything (e.g. kubectl exec -it prod-api /bin/sh
). Since typescript
isn't a dependency, the temporary package downloaded by npx ts-node
throws this error.
You can get around this by telling npx
to also download a temporary copy of typescript
:
npx -p typescript -p ts-node ts-node
(tested with npx v6.14.8)
The new npm installs peer dependencies automatically. Does that mean the
new npx also auto-installs it? I haven't tested this but I've been
wondering if this new auto-install behavior is good or bad for ts-node. It
sounds like in your case it's a good thing.
On Fri, May 7, 2021, 1:22 PM Tim ***@***.***> wrote:
Once in a while, I'm in a stripped-down environment where I'd like to run
ts-node via npx without permanently installing
<
https://nodejs.dev/learn/the-npx-nodejs-package-runner#installation-less-command-execution>
anything (e.g. kubectl exec -it prod-api /bin/sh). Since typescript isn't
a dependency, the temporary package downloaded by npx ts-node throws this
error.
You can get around this by telling npx to also download a temporary copy
of typescript:
npx -p typescript -p ts-node ts-node
(tested with npx v6.14.8)
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<
#707 (comment)>,
or unsubscribe
<
https://github.com/notifications/unsubscribe-auth/AAC35OBET2JS3Z7JAEL6DB3TMQOTRANCNFSM4F3H4SSA>
@cspotcode Ah, yep, updating to npm v7.12.0, I see npx
is deprecated in favor of a stripped-down version invoked with npm x
. It now interactively prompts about downloading packages, suppressed with -y
, so this gets me a REPL without errors in the new npm:
npm x -y ts-node
had "ts-node" and "typescript" installed globally. was still showing error.
i was missing tsconfig.json file.... which you can generate by running
tsc --init