deligenius / view-engine

🚀A Template View Engine for Deno frameworks
MIT License
54 stars 15 forks source link

Error while trying example code from https://deno.land/x/view_engine #13

Closed tinkajts closed 3 years ago

tinkajts commented 3 years ago

Getting this error while trying your example code: Executing with Deno ver 1.2 on windows 10:

deno run --reload --allow-net --allow-read fix.ts

error: TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'. Type 'URL' is not assignable to type 'string'. return new URL(url).pathname

    at https://deno.land/std@0.58.0/path/win32.ts:917:18

TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'.
  Type 'URL' is not assignable to type 'string'.
  return new URL(url).pathname;
at https://deno.land/std@0.58.0/path/posix.ts:438:18

Found 2 errors.


If i update to Oak ver 6.0.0 and drop the version 1.2.0 for the View-engine import, then the ctx.render function is missing, but then there's no issue with the url.

What to do?

tinkajts commented 3 years ago

if i use std@0.61.0 , but on some other code, then the issue with with

"error: TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'. Type 'URL' is not assignable to type 'string'. return new URL(url).pathname"

is gone.

gjuoun commented 3 years ago

view-engine v1.2 is supposed to work with oak@v5.3.1 and Deno < v1.20

https://github.com/deligenius/view-engine/releases/tag/v1.2.0

I'm going to release a new version soon

gjuoun commented 3 years ago

Please try view-engine v1.3, let me know if you still have issues.

https://github.com/deligenius/view-engine/releases/tag/v1.3.0

tinkajts commented 3 years ago

Thanks for the new version :)

No luck :( copy-pasted your example code.

Windows10 - deno 1.2.

Terminal output:

C:\Data\prosjekter\denoworld> deno run --reload --allow-net fix.ts Download https://deno.land/x/oak@v6.0.0/mod.ts Download https://deno.land/x/view_engine@v1.3.0/mod.ts Download https://deno.land/x/view_engine@v1.3.0/lib/types/index.ts Download https://deno.land/x/view_engine@v1.3.0/lib/engineFactory.ts Download https://deno.land/x/view_engine@v1.3.0/lib/adapterFactory.ts Download https://deno.land/x/view_engine@v1.3.0/lib/viewEngine.ts Download https://deno.land/x/view_engine@v1.3.0/lib/engines/denjuck.ts Download https://deno.land/x/view_engine@v1.3.0/lib/engines/ejs.ts Download https://deno.land/x/view_engine@v1.3.0/lib/engines/handlebars.ts Download https://deno.land/x/oak@v6.0.0/application.ts Download https://deno.land/x/oak@v6.0.0/body.ts Download https://deno.land/x/oak@v6.0.0/context.ts Download https://deno.land/x/oak@v6.0.0/helpers.ts Download https://deno.land/x/oak@v6.0.0/cookies.ts Download https://deno.land/x/oak@v6.0.0/httpError.ts Download https://deno.land/x/oak@v6.0.0/middleware.ts Download https://deno.land/x/oak@v6.0.0/multipart.ts Download https://deno.land/x/oak@v6.0.0/request.ts Download https://deno.land/x/oak@v6.0.0/response.ts Download https://deno.land/x/oak@v6.0.0/router.ts Download https://deno.land/x/oak@v6.0.0/send.ts Download https://deno.land/x/oak@v6.0.0/server_sent_event.ts Download https://deno.land/x/oak@v6.0.0/types.d.ts Download https://deno.land/x/oak@v6.0.0/util.ts Download https://deno.land/x/oak@v6.0.0/deps.ts Download https://deno.land/x/view_engine@v1.3.0/lib/adapters/oak.ts Download https://deno.land/x/denjucks/mod.js Download https://deno.land/x/denjucks/mod.d.ts Download https://dev.jspm.io/handlebars@4.7.6 Download https://deno.land/x/view_engine@v1.3.0/lib/engines/ejs/mod.ts Download https://deno.land/x/view_engine@v1.3.0/deps.ts Download https://deno.land/std@0.61.0/bytes/mod.ts Download https://deno.land/std@0.61.0/hash/sha1.ts Download https://deno.land/std@0.61.0/hash/sha256.ts Download https://deno.land/std@0.61.0/http/server.ts Download https://deno.land/std@0.61.0/http/http_status.ts Download https://deno.land/std@0.61.0/io/bufio.ts Download https://deno.land/std@0.61.0/path/mod.ts Download https://deno.land/std@0.61.0/testing/asserts.ts Download https://deno.land/std@0.61.0/ws/mod.ts Download https://deno.land/x/media_types@v2.4.2/mod.ts Download https://raw.githubusercontent.com/pillarjs/path-to-regexp/v6.1.0/src/index.ts Download https://deno.land/x/oak@v6.0.0/keyStack.ts Download https://deno.land/std@0.61.0/fmt/colors.ts Download https://deno.land/std@0.61.0/path/win32.ts Download https://deno.land/x/oak@v6.0.0/negotiation/charset.ts Download https://deno.land/x/oak@v6.0.0/negotiation/encoding.ts Download https://deno.land/x/oak@v6.0.0/negotiation/language.ts Download https://deno.land/x/oak@v6.0.0/negotiation/mediaType.ts Download https://deno.land/x/oak@v6.0.0/isMediaType.ts Download https://deno.land/x/oak@v6.0.0/buf_reader.ts Download https://deno.land/x/oak@v6.0.0/content_disposition.ts Download https://deno.land/x/oak@v6.0.0/headers.ts Download https://deno.land/std@0.61.0/fs/exists.ts Download https://deno.land/x/view_engine@v1.3.0/lib/utils/utils.ts Download https://deno.land/x/denjucks/src/lib.js Download https://deno.land/x/denjucks/src/environment.js Download https://deno.land/x/denjucks/src/loader.js Download https://deno.land/x/denjucks/src/loaders.js Download https://deno.land/x/denjucks/src/precompile.js Download https://deno.land/x/denjucks/src/compiler.js Download https://deno.land/x/denjucks/src/parser.js Download https://deno.land/x/denjucks/src/lexer.js Download https://deno.land/x/denjucks/src/runtime.js Download https://deno.land/x/denjucks/src/nodes.js Download https://deno.land/x/denjucks/src/jinja-compat.js Download https://deno.land/x/view_engine@v1.3.0/lib/engines/ejs/ejs.js Download https://deno.land/x/view_engine@v1.3.0/lib/engines/ejs/ejs.d.ts Download https://deno.land/std@0.61.0/_util/assert.ts Download https://deno.land/std@0.61.0/encoding/utf8.ts Download https://deno.land/std@0.61.0/async/mod.ts Download https://deno.land/std@0.61.0/http/_io.ts Download https://deno.land/std@0.61.0/path/_interface.ts Download https://deno.land/std@0.61.0/path/_constants.ts Download https://deno.land/std@0.61.0/path/_util.ts Download https://deno.land/x/media_types@v2.4.2/db.ts Download https://deno.land/x/media_types@v2.4.2/deps.ts Download https://deno.land/std@0.61.0/path/posix.ts Download https://deno.land/std@0.61.0/path/common.ts Download https://deno.land/std@0.61.0/path/separator.ts Download https://deno.land/std@0.61.0/path/glob.ts Download https://deno.land/std@0.61.0/_util/has_own_property.ts Download https://deno.land/std@0.61.0/io/ioutil.ts Download https://deno.land/std@0.61.0/textproto/mod.ts Download https://deno.land/std@0.61.0/async/deferred.ts Download https://deno.land/x/oak@v6.0.0/negotiation/common.ts Download https://deno.land/x/oak@v6.0.0/tssCompare.ts Download https://deno.land/std@0.61.0/testing/diff.ts Download https://deno.land/x/oak@v6.0.0/mediaTyper.ts Download https://deno.land/std@0.61.0/async/delay.ts Download https://deno.land/std@0.61.0/async/mux_async_iterator.ts Download https://deno.land/std@0.61.0/path/_globrex.ts Download https://dev.jspm.io/npm:handlebars@4.7.6/lib/index.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/compiler/printer.dew.js Download https://dev.jspm.io/npm:@jspm/core@1/nodelibs/fs.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars.runtime.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/compiler/ast.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/compiler/base.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/compiler/compiler.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/compiler/javascript-compiler.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/compiler/visitor.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/no-conflict.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/base.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/safe-string.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/exception.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/utils.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/runtime.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/helpers.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/decorators.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/logger.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/internal/proto-access.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/helpers/block-helper-missing.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/helpers/each.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/helpers/helper-missing.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/helpers/if.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/helpers/log.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/helpers/lookup.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/helpers/with.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/decorators/inline.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/internal/create-new-lookup-object.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/internal/wrapHelper.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/compiler/parser.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/compiler/whitespace-control.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/compiler/helpers.dew.js Download https://dev.jspm.io/npm:handlebars@4.7.6/dist/cjs/handlebars/compiler/code-gen.dew.js Download https://dev.jspm.io/npm:source-map@0.6?dew Download https://dev.jspm.io/npm:@jspm/core@1.1.1/nodelibs/fs.js Download https://dev.jspm.io/npm:source-map@0.6.1/source-map.dew.js Download https://dev.jspm.io/npm:source-map@0.6.1/lib/source-map-generator.dew.js Download https://dev.jspm.io/npm:source-map@0.6.1/lib/source-map-consumer.dew.js Download https://dev.jspm.io/npm:source-map@0.6.1/lib/source-node.dew.js Download https://dev.jspm.io/npm:source-map@0.6.1/lib/base64-vlq.dew.js Download https://dev.jspm.io/npm:source-map@0.6.1/lib/util.dew.js Download https://dev.jspm.io/npm:source-map@0.6.1/lib/array-set.dew.js Download https://dev.jspm.io/npm:source-map@0.6.1/lib/mapping-list.dew.js Download https://dev.jspm.io/npm:source-map@0.6.1/lib/base64.dew.js Download https://dev.jspm.io/npm:source-map@0.6.1/lib/binary-search.dew.js Download https://dev.jspm.io/npm:source-map@0.6.1/lib/quick-sort.dew.js Download https://deno.land/x/denjucks/src/node-loaders.js Download https://deno.land/x/denjucks/src/object.js Download https://deno.land/x/denjucks/src/deps.js Download https://deno.land/x/denjucks/src/precompile-global.js Download https://deno.land/x/denjucks/src/transformer.js Download https://deno.land/x/view_engine@v1.3.0/lib/engines/ejs/utils.js Download https://deno.land/x/denjucks/src/filters.js Download https://deno.land/x/denjucks/src/globals.js Download https://deno.land/x/denjucks/src/precompiled-loader.js Download https://deno.land/std@0.59.0/path/mod.ts Download https://cdn.pika.dev/asap/^2.0.6 Download https://jspm.dev/npm:a-sync-waterfall@1.0.1 Download https://deno.land/x/denjucks/src/waterfall.d.ts Download https://deno.land/std@0.59.0/path/_constants.ts Download https://deno.land/std@0.59.0/path/win32.ts Download https://deno.land/std@0.59.0/path/posix.ts Download https://deno.land/std@0.59.0/path/common.ts Download https://deno.land/std@0.59.0/path/separator.ts Download https://deno.land/std@0.59.0/path/_interface.ts Download https://deno.land/std@0.59.0/path/glob.ts Download https://jspm.dev/npm:@jspm/core@2/nodelibs/process Download https://jspm.dev/npm:a-sync-waterfall@1.0.1!cjs Download https://cdn.pika.dev/-/asap@v2.0.6-MSBsRoNpzCyRXXLcQdOC/dist=es2019,mode=types/index.d.ts Download https://cdn.pika.dev/-/asap@v2.0.6-MSBsRoNpzCyRXXLcQdOC/dist=es2019/asap.js Download https://deno.land/std@0.59.0/path/_util.ts Download https://deno.land/std@0.59.0/_util/assert.ts Download https://deno.land/std@0.59.0/path/_globrex.ts Download https://jspm.dev/npm:@jspm/core@2.0.0-beta.7/_/de9a8dfb.js Check file:///C:/Data/prosjekter/denoworld/fix.ts error: Failed to get compiled source code of https://deno.land/std@0.59.0/path/mod.ts. Reason: Systemet finner ikke angitt bane. (os error 3)

Last line translates to "The system can't find the path (os error 3)"

Later today i'll try on Ubuntu 20.04.

tinkajts commented 3 years ago

Hi again, works perfect on Ubuntu 20.04 with Deno 1.2.0. I noticed i didn't add --allow-read on the windows test. Will doublecheck with this flag tomorrow, but probably it will not work, since the deno server did not start on Windows at all, but did on Ubuntu without this flag. Got an error in the console when tied to access localhost:8000 without this --allow-read-flag on Ubuntu setup.

gjuoun commented 3 years ago

Sometimes I just used -A flag for testing purposes. You may try that, too.

tinkajts commented 3 years ago

Sadly, but no luck in Windows 10... Even with the -A. So i quess this is related to Deno compiler, not your code. So waiting it'll be.

gjuoun commented 3 years ago

Still no luck?

spedy commented 3 years ago

Looks like you are installing multiple versions of std lib.

The last function fromFileUrl doesn't check if url is instanceof URL.

Download https://deno.land/std@0.59.0/path/_constants.ts
Download https://deno.land/std@0.59.0/path/win32.ts
Download https://deno.land/std@0.59.0/path/posix.ts

The issue should be fixed in the latest versions.

gjuoun commented 3 years ago

Please use the newest version 1.4.0, denjucks is removed temporarily.