I'd like to import from local
Testing environment Deno v1.6.0
I've tried local import by Deno lang
Local directory
.
└── src
└── sample
├── hello_world.ts
├── httpRequest.ts
├── localExport
│ └── arithmetic.ts
├── localImport.ts
'./localExport/arithmetic.ts' File to be imported
function add(outbound: number, inbound: number): number {
return outbound + inbound
}
function multiply(sum: number, tax: number): number {
return sum * tax
}
'./localImport.ts' File to run
import { add, multiply } from "./localImport/arithmetic.ts";
function totalCost(outbound: number, inbound: number, tax: number): number {
return multiply(add(outbound, inbound), tax);
}
console.log(totalCost(19, 31, 1.2));
console.log(totalCost(45, 27, 1.15));
Run the above codes
❯ deno run src/sample/localImportExport.ts
I got the errors:
❯ deno run src/sample/localImportExport.ts
error: Uncaught SyntaxError: The requested module './localImport/arithmetic.ts' does not provide an export named 'add'
import { add, multiply } from "./localImport/arithmetic.ts";
~~~
at <anonymous> (file:///Users/ko-kamenashi/Desktop/Samples/Deno/deno-sample/src/sample/localImportExport.ts:1:10)
What should I do?