Linked Questions
12 questions linked to/from Typescript: Cannot use import statement outside a module
6
votes
2
answers
3k
views
Cannot use import statement outside a module, TypeScript NodeJS Firebase Functions project
I recently set up a Firebase Functions project using TypeScript. As far as I can tell I am using the same setup I have before in the past. This time, however, when I run firebase emulators:start I ...
2
votes
1
answer
2k
views
Manually compiling a TypeScript library
I'm creating a TS library the build for which involves parsing TS code, generating types and additional variables from it in a complex and custom process (ie, not just by running it through a ...
1
vote
2
answers
2k
views
Configuring TypeScript `tsconfig.json` for ES modules?
My Firebase Cloud Functions, which use ES modules (import and export, not require and exports), are running in JavaScript but not in TypeScript. I'm getting this error:
SyntaxError: Cannot use import ...
0
votes
1
answer
1k
views
"SyntaxError: Cannot use import statement outside a module" in TypeScript (nodemon) and Node.js (with Docker)
In the server directory of my web app (in TypeScript), I have a nodemon command (that reruns code after changes) like this:
nodemon dist/index.js
However, running it now throws this error:
/path/to/...
0
votes
1
answer
931
views
Node12/next9 SyntaxError: Cannot use import statement outside a module
I have been trying to run a project in debug mode for quite a long time and I get an import error, I have already studied a lot of information on this issue and decided to move along the path of ...
1
vote
0
answers
1k
views
inability to use `ts-node` or `node` to serve `index.ts` file but `nodemon` works... why?
Have been wrestling with this for a couple days now... Writing a TypeScript, React, Express, Node, Webpack and Babel project. First, I was getting the SyntaxError: Cannot use import statement outside ...
1
vote
1
answer
557
views
TS ERR_REQUIRE_ESM -> Cannot use import statement outside a module -> ERR_UNKNOWN_FILE_EXTENSION -> repeat
I've been stuck in an error cycle for hours. I want to have a TypeScript project but each "solution" to each error just moves to another error and it cycles.
It starts with ERR_REQUIRE_ESM ...
2
votes
1
answer
616
views
Problems with converting the notepad example of proton-native from js to tsx
I try to convert the Notepad example from the proton-native repository into Typescript. I ran into some issues I could not fix.
Code:
TSConfig:
{
"compilerOptions": {
"strict": ...
3
votes
1
answer
442
views
How to get VS Code to show / validate object schema?
npm init -y
npm i axios
npm i @types/axios --save-dev
How come VS code 1.62 doesn't appear to give the schema of the response object when I am typing out code like:
resp = await axios("https://...
0
votes
1
answer
179
views
the Example code of TS can't run but return an Error
In the website https://react-typescript-cheatsheet.netlify.app/,I want learn more about the TS,so I want to run the Example code of TS,then I want I can get a result of these Example code,however ,I ...
0
votes
1
answer
64
views
Compiler not complaining when importing constant that doesn't exist
I am writing a Node application using TypeScript.
When using npm run dev, the following code compiles without problems and prints undefined at runtime.
index.ts:
import { a } from './some-file.ts';
...
0
votes
0
answers
30
views
Typescript files to JS
I have project on express using typescript. When i try to use tsc to convert typescript files to js and create build folder, It's creating and everything is fine but when i try to start server in ...