There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
You can also find further discussion and get answers to your questions over in Language Help.
Agree with a comment or answer? Like () to up-vote the contribution!
I’m not sure this is working correctly. When I run it, I get this error:
$ node index.ts
(node:97) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
/home/ccuser/workspace/typescript-functions-explicit-return-types/index.ts:1
import {getUserChoice,f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12} from './resources'
^^^^^^
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 Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
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 internal/main/run_main_module.js:17:47
In order to get a hint about where the problematic function is, you need to run the tsc command on the bash.
It’s been some time since you asked but I hope you find my answer useful.
I can’t see which function has the problem, tsc error says:
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
internal/bootstrap/switches/does_own_process_state.js:128
cachedCwd = rawMethods.cwd();
^
Error: ENOENT: no such file or directory, uv_cwd
at process.wrappedCwd [as cwd] (internal/bootstrap/switches/does_own_process_state.js:128:26)
at /usr/lib/node_modules/typescript/lib/tsc.js:4495:79
at Object.getCurrentDirectory (/usr/lib/node_modules/typescript/lib/tsc.js:1323:25)
at executeCommandLineWorker (/usr/lib/node_modules/typescript/lib/tsc.js:97448:51)
at Object.executeCommandLine (/usr/lib/node_modules/typescript/lib/tsc.js:97530:20)
at Object.<anonymous> (/usr/lib/node_modules/typescript/lib/tsc.js:97818:4)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14) {
errno: -2,
code: 'ENOENT',
syscall: 'uv_cwd'
}
I have the same issue. Not sure how the error could help me find out which function is problematic. Here’s what I see in the console:
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
internal/bootstrap/switches/does_own_process_state.js:128
cachedCwd = rawMethods.cwd();
^
Error: ENOENT: no such file or directory, uv_cwd
at process.wrappedCwd [as cwd] (internal/bootstrap/switches/does_own_process_state.js:128:26)
at /usr/lib/node_modules/typescript/lib/tsc.js:4495:79
at Object.getCurrentDirectory (/usr/lib/node_modules/typescript/lib/tsc.js:1323:25)
at executeCommandLineWorker (/usr/lib/node_modules/typescript/lib/tsc.js:97448:51)
at Object.executeCommandLine (/usr/lib/node_modules/typescript/lib/tsc.js:97530:20)
at Object.<anonymous> (/usr/lib/node_modules/typescript/lib/tsc.js:97818:4)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14) {
errno: -2,
code: 'ENOENT',
syscall: 'uv_cwd'
}
Please assist us by looking into this issue if possible?
$ tsc
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
internal/bootstrap/switches/does_own_process_state.js:128
cachedCwd = rawMethods.cwd();
^
Error: ENOENT: no such file or directory, uv_cwd
at process.wrappedCwd [as cwd] (internal/bootstrap/switches/does_own_process_state.js:128:26)
at /usr/lib/node_modules/typescript/lib/tsc.js:4495:79
at Object.getCurrentDirectory (/usr/lib/node_modules/typescript/lib/tsc.js:1323:25)
at executeCommandLineWorker (/usr/lib/node_modules/typescript/lib/tsc.js:97448:51)
at Object.executeCommandLine (/usr/lib/node_modules/typescript/lib/tsc.js:97530:20)
at Object.<anonymous> (/usr/lib/node_modules/typescript/lib/tsc.js:97818:4)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14) {
errno: -2,
code: 'ENOENT',
syscall: 'uv_cwd'
}
$ node index.ts
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
node:internal/bootstrap/switches/does_own_process_state:126
cachedCwd = rawMethods.cwd();
^
Error: ENOENT: no such file or directory, uv_cwd
at process.wrappedCwd [as cwd] (node:internal/bootstrap/switches/does_own_process_state:126:28)
at node:path:1082:24
at Object.resolve (node:path:1096:39)
at resolveMainPath (node:internal/modules/run_main:19:40)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:71:24)
at node:internal/main/run_main_module:17:47 {
errno: -2,
code: 'ENOENT',
syscall: 'uv_cwd'
}
Hello, as of 12/22/22 this is still happening at least for me, the exercise does not appear to be working. I am getting the same error that @pudpark reported in April
In pupark’s screenshot, node index.ts has been entered in the terminal. Instead it should have been node index.js as indicated in the hints as well. If that doesn’t help, then consider the questions I asked in the post above yours.
$ node index.js
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
node:internal/bootstrap/switches/does_own_process_state:126
cachedCwd = rawMethods.cwd();
^
Error: ENOENT: no such file or directory, uv_cwd
at process.wrappedCwd [as cwd] (node:internal/bootstrap/switches/does_own_process_state:126:28)
at node:path:1082:24
at Object.resolve (node:path:1096:39)
at resolveMainPath (node:internal/modules/run_main:19:40)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:71:24)
at node:internal/main/run_main_module:17:47 {
errno: -2,
code: ‘ENOENT’,
syscall: ‘uv_cwd’
}
$