You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a project created using create-react-app xxx --template typescript.
I want to add some custom scripts to to miscellaneous things.
Here is my script in scripts/xxx.ts
importfsfrom"fs";console.log("ttt",fs.readFile);
Steps to reproduce
create-react-app xxx --template typescript
add the script
ts-node scripts/xxx.ts
Expected behavior
script runs successfully
Actual behavior
(node:50658) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
/Users/kdong007/Desktop/projects/tapin-monorepo/test-react/scripts/tt.ts:1
import fs from "fs";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1053:16)
at Module._compile (internal/modules/cjs/loader.js:1101:27)
at Module.m._compile (/Users/kdong007/.config/yarn/global/node_modules/ts-node/src/index.ts:1043:23)
at Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Object.require.extensions.<computed> [as .ts] (/Users/kdong007/.config/yarn/global/node_modules/ts-node/src/index.ts:1046:12)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at main (/Users/kdong007/.config/yarn/global/node_modules/ts-node/src/bin.ts:225:14)
at Object.<anonymous> (/Users/kdong007/.config/yarn/global/node_modules/ts-node/src/bin.ts:512:3)
Reproducible demo
(Paste the link to an example project and exact instructions to reproduce the issue.)
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.
Describe the bug
I have a project created using
create-react-app xxx --template typescript
.I want to add some custom scripts to to miscellaneous things.
Here is my script in
scripts/xxx.ts
Steps to reproduce
create-react-app xxx --template typescript
ts-node scripts/xxx.ts
Expected behavior
script runs successfully
Actual behavior
Reproducible demo
(Paste the link to an example project and exact instructions to reproduce the issue.)
The text was updated successfully, but these errors were encountered: