-
-
Notifications
You must be signed in to change notification settings - Fork 529
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 'typescript' #707
Comments
I try to run |
TypeScript is required if you want to compile using |
I have this issue with typescript installed globally. Here is the error: Error: Cannot find module 'typescript' npm ERR! A complete log of this run can be found in: Happens with the following packages: |
ts-node need installed globally too. or both installed locally |
same problem |
You'll need to install |
@blakeembrey It would be really nice to be able to run this with |
@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. |
@blakeembrey putting it behind a flag would be just fine for me, sounds good. Question of course is what should the flag be called, shall we bikeshed? :) how about |
Why do it need to be behind a flag? Cant you just do a fallback if typescript isn't installed locally, search for globally? |
@codler That creates an inconsistent environment for people, e.g. a dev environment may have it installed locally and another person not installed locally. This can create simple misunderstandings and more issues. |
Hm, locally is bound to a project in package.json, and when its bound to project I cant see how the other person wouldn't have it locally also without installed the project wrongly. |
What about if you never did |
As a temporary solution I used these settings: |
@Redfish52 I'm not sure what that's working around, but |
Any progress on the flag? |
What if you defaulted to using the global |
@jajaperson #707 (comment). You can always submit a PR too, it's a relatively small change. |
I have stumbled across this same issue just now.
In ts file:
tsconfig:
If I change module to
it is able to find typescript. But with "ES6" option it magically loses this ability
|
I solve this problem by reinstalling typescript globally |
I had to do a reinstall of my local node modules then it worked. |
I tried to reinstall the
or
Try one way, and if it still don't work, then try the other way. |
|
This did the trick for me.
|
i have no idea why this occurred, but the command |
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:
This
<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>
.
|
I fixed mine by typing |
@Jood80 thanks also fixed my error |
直接进入blinker-js目录,然后运行 npm install typescript 就能解决问了! |
this worked for me as well ,thank you! |
Once in a while, I'm in a stripped-down environment where I'd like to run You can get around this by telling
(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
|
had "ts-node" and "typescript" installed globally. was still showing error. i was missing tsconfig.json file.... which you can generate by running
|
when I execute:
$ npx ts-node
, it throwingCannot find module 'typescript'
how should I fix that?
tsconfig.json
src/index.ts
package.json
The text was updated successfully, but these errors were encountered: