-1

I installed liquid.js for Nodejs following the official instruction as:

Install to Nodejs

But the instruction page does not mention on deno at all.

Please help me to install the library in deno.

Or at least I want to know how to copy the library from node_modules dir to my deno's project.

npm install --save liquidjs
var { Liquid } = require('liquidjs');
var engine = new Liquid();

engine
    .parseAndRender('{{name | capitalize}}', {name: 'alice'})
    .then(console.log);     // outputs 'Alice'

skatori
  • 547
  • 6
  • 20

2 Answers2

2

Deno packages and Node packages are not really the same. Node uses a system called NPM to handle all packages. Deno has its own packaging system, where you import the packages directly into the project by URL.

There is however a Deno library who can handle some npm packages, that do not use non-polyfilled API's. You may try:

import { createRequire } from "https://deno.land/std/node/module.ts";

const require = createRequire(import.meta.url);
const liquidjs = require("liquidjs");

// do tuff with liquidjs

Deno is a very secure system, which means you won't be able to just read from the node_modules directory without explicitly telling so.
You have to run your program with:

deno run --allow-read liquidjs
harttle
  • 88
  • 1
  • 12
1
import { Liquid } from 'liquidjs';
const engine = new Liquid();

engine
    .parseAndRender('{{name | capitalize}}', {name: 'alice'})
    .then(console.log);     // outputs 'Alice'

Type definitions for LiquidJS are also exported and published, within the same package so, installing @types for the package is unnecessary.

Resource:

https://liquidjs.com/tutorials/setup.html

TheoNeUpKID
  • 763
  • 7
  • 11