Reputation: 2256
I know Deno
was recently release but I want to implement a presentation using it to show some nice features and I had this problem when I tried to import some of it third-party modules.
I tried it four ways:
import Fiona from 'https://deno.land/x/fiona';
import Fiona from 'https://deno.land/x/fiona/index.js';
import * as Fiona from 'https://deno.land/x/fiona/index.js';
import { Fiona } from 'https://deno.land/x/fiona/core/index.js';
Unfortunately I still get the error Cannot find module "https://deno.land/x/fiona"
. Can someone help?
Upvotes: 4
Views: 2304
Reputation: 40414
The imports that works on that package are:
import Fiona from 'https://deno.land/x/fiona/deno/index.js'
const seeded = Fiona(2983938);
const data = seeded.object({
name: Fiona.Fullname,
age: Fiona.Number({ max: 100 }),
});
console.log(data); // { name: "Miss Fiona Moon", age: 1 }
or
import bootstrap from 'https://deno.land/x/fiona/bootstrap.js'
const Fiona = bootstrap();
const seeded = Fiona(2983938);
const data = seeded.object({
name: Fiona.Fullname,
age: Fiona.Number({ max: 100 }),
});
console.log(data); // { name: "Miss Fiona Moon", age: 1 }
import Fiona from 'https://deno.land/x/fiona/index.js';
The above import fails with:
error: relative import path "randexp" not prefixed with / or ./ or ../ Imported from "https://deno.land/x/fiona/index.js"
Because there's an error in index.js
since the package is doing:
import RandExp from 'randexp'
Which isn't valid for Deno. That's the index.js
for Node.js
import Fiona from 'https://deno.land/x/fiona';
This one fails because unlike Node.js, Deno does not load index.js
by default when you import a folder.
Upvotes: 3
Reputation: 15124
This will work:
import Fiona from 'https://deno.land/x/fiona/deno/index.js'
var version = Fiona.version
console.log(version)
Found on the documentation.
Upvotes: 4