Open8
line-bot-sdk-nodejsをdenoで使えるようにしたい
ここにアップされてたら使えるかも?
お、あった
ファイルを作って、deno run index.ts
を実行してみる
index.ts
import lineBotSdk from 'https://cdn.skypack.dev/@line/bot-sdk';
deno run index.ts
Download https://cdn.skypack.dev/@line/bot-sdk
Download https://cdn.skypack.dev/-/@line/bot-sdk@v7.4.0-EMA7K1AXonuhlYXSGuO4/dist=es2020,mode=imports/optimized/@line/bot-sdk.js
Download https://cdn.skypack.dev/-/axios@v0.21.4-2rarrxxdfJtXE4yFvxtx/dist=es2020,mode=imports/optimized/axios.js
Download https://cdn.skypack.dev/-/body-parser@v1.19.0-aj3W13yq6EU7azhxcprK/dist=es2020,mode=imports/optimized/body-parser.js
Download https://cdn.skypack.dev/-/file-type@v15.0.1-pV4xjNEAGySxdUlLySR7/dist=es2020,mode=imports/optimized/file-type.js
Download https://cdn.skypack.dev/-/form-data@v3.0.1-Aw0DwpadVKMMzzxUqO8F/dist=es2020,mode=imports/optimized/form-data.js
Download https://cdn.skypack.dev/error/node:node:crypto?from=@line/bot-sdk
Download https://deno.land/std/node/crypto.ts
Download https://deno.land/std/node/string_decoder.ts
Warning Implicitly using latest version (0.113.0) for https://deno.land/std/node/string_decoder.ts
Download https://deno.land/std@0.113.0/node/string_decoder.ts
Warning Implicitly using latest version (0.113.0) for https://deno.land/std/node/crypto.ts
Download https://deno.land/std@0.113.0/node/crypto.ts
Download https://cdn.skypack.dev/-/strtok3@v6.2.4-5FePyU4JO1AsJEam2V6Y/dist=es2020,mode=imports/optimized/strtok3.js
Download https://cdn.skypack.dev/-/strtok3@v6.2.4-5FePyU4JO1AsJEam2V6Y/dist=es2020,mode=imports/unoptimized/lib/core.js
Download https://cdn.skypack.dev/-/token-types@v2.1.1-Cd2laXUSJaYsNvYyZgLe/dist=es2020,mode=imports/optimized/token-types.js
Download https://deno.land/std@0.113.0/_wasm_crypto/mod.ts
Download https://deno.land/std@0.113.0/encoding/base64.ts
Download https://deno.land/std@0.113.0/encoding/hex.ts
Download https://deno.land/std@0.113.0/node/_crypto/pbkdf2.ts
Download https://deno.land/std@0.113.0/node/_crypto/randomBytes.ts
Download https://deno.land/std@0.113.0/node/_crypto/randomFill.ts
Download https://deno.land/std@0.113.0/node/_crypto/randomInt.ts
Download https://deno.land/std@0.113.0/node/_crypto/scrypt.ts
Download https://deno.land/std@0.113.0/node/_crypto/timingSafeEqual.ts
Download https://deno.land/std@0.113.0/node/_stream/transform.ts
Download https://deno.land/std@0.113.0/node/buffer.ts
Download https://deno.land/std@0.113.0/node/stream.ts
Download https://deno.land/std@0.113.0/node/_utils.ts
Download https://cdn.skypack.dev/-/bytes@v3.1.0-NqEXITlnd7zr5JaWekjZ/dist=es2020,mode=imports/optimized/bytes.js
Download https://cdn.skypack.dev/-/content-type@v1.0.4-kaoJBZGFgrezvUp526Iu/dist=es2020,mode=imports/optimized/content-type.js
Download https://cdn.skypack.dev/-/debug@v2.6.9-54wuzQ0pfeO59pDEqNbR/dist=es2020,mode=imports/optimized/debug.js
Download https://cdn.skypack.dev/-/depd@v1.1.2-y8i91iSBwcfqwKyxqXYj/dist=es2020,mode=imports/optimized/depd.js
Download https://cdn.skypack.dev/-/http-errors@v1.7.2-0l0m57UfNlocHZYEcp5l/dist=es2020,mode=imports/optimized/http-errors.js
Download https://cdn.skypack.dev/-/iconv-lite@v0.4.24-ggaFO8BTtgJzxF1frvRA/dist=es2020,mode=imports/optimized/iconv-lite.js
Download https://cdn.skypack.dev/-/on-finished@v2.3.0-DQUAkbdQ0tTQkddZX2m0/dist=es2020,mode=imports/optimized/on-finished.js
Download https://cdn.skypack.dev/-/qs@v6.7.0-51El07saBsjWXaEjf40D/dist=es2020,mode=imports/optimized/qs.js
Download https://cdn.skypack.dev/-/raw-body@v2.4.0-PDDM1aXulklt71eFPnU8/dist=es2020,mode=imports/optimized/raw-body.js
Download https://cdn.skypack.dev/-/type-is@v1.6.18-y36C32LQ0zxgz36wnxgT/dist=es2020,mode=imports/optimized/type-is.js
Download https://cdn.skypack.dev/error/node:zlib?from=body-parser
Download https://cdn.skypack.dev/-/safer-buffer@v2.1.2-Djsa36x9gcnWFsoW39YK/dist=es2020,mode=imports/optimized/safer-buffer.js
Download https://deno.land/std@0.113.0/_wasm_crypto/crypto.js
Download https://deno.land/std@0.113.0/_wasm_crypto/crypto.wasm.js
Download https://deno.land/std@0.113.0/node/_errors.ts
Download https://deno.land/std@0.113.0/node/_stream/duplex.ts
Download https://deno.land/std@0.113.0/node/_stream/writable_internal.ts
Download https://deno.land/std@0.113.0/node/_crypto/constants.ts
Download https://deno.land/std@0.113.0/node/_crypto/types.ts
Download https://deno.land/std@0.113.0/node/_stream/end_of_stream.ts
Download https://deno.land/std@0.113.0/node/_stream/passthrough.ts
Download https://deno.land/std@0.113.0/node/_stream/pipeline.ts
Download https://deno.land/std@0.113.0/node/_stream/promises.ts
Download https://deno.land/std@0.113.0/node/_stream/readable.ts
Download https://deno.land/std@0.113.0/node/_stream/stream.ts
Download https://deno.land/std@0.113.0/node/_stream/writable.ts
Download https://deno.land/std@0.113.0/async/mod.ts
Download https://deno.land/std@0.113.0/streams/conversion.ts
Download https://deno.land/std@0.113.0/testing/asserts.ts
Download https://cdn.skypack.dev/-/ieee754@v1.2.1-wxdRuKvQQOTpW1dpWzFI/dist=es2020,mode=imports/optimized/ieee754.js
Download https://deno.land/std@0.113.0/node/_stream/symbols.ts
Download https://deno.land/std@0.113.0/node/_util/_debuglog.ts
Download https://deno.land/std@0.113.0/node/events.ts
Download https://deno.land/std@0.113.0/node/_stream/async_iterator.ts
Download https://deno.land/std@0.113.0/node/_stream/duplex_internal.ts
Download https://deno.land/std@0.113.0/node/_stream/readable_internal.ts
Download https://cdn.skypack.dev/-/strtok3@v6.2.4-5FePyU4JO1AsJEam2V6Y/dist=es2020,mode=imports/unoptimized/lib/BufferTokenizer.js
Download https://cdn.skypack.dev/-/strtok3@v6.2.4-5FePyU4JO1AsJEam2V6Y/dist=es2020,mode=imports/unoptimized/lib/ReadStreamTokenizer.js
Download https://cdn.skypack.dev/-/peek-readable@v4.0.1-cCGyNYELFw0KFCQGAZwl/dist=es2020,mode=imports/optimized/peek-readable.js
Download https://cdn.skypack.dev/error/node:node:fs?from=strtok3
Download https://deno.land/std/node/fs.ts
Download https://deno.land/std@0.113.0/node/util.ts
Download https://cdn.skypack.dev/-/ms@v2.0.0-sDRwV9gszq6kRqF5gFMP/dist=es2020,mode=imports/optimized/ms.js
Download https://cdn.skypack.dev/-/ee-first@v1.1.1-cpbMmVDoDS6efpdjVdWi/dist=es2020,mode=imports/optimized/ee-first.js
Download https://deno.land/std@0.113.0/node/_stream/destroy.ts
Download https://deno.land/std@0.113.0/async/deadline.ts
Download https://deno.land/std@0.113.0/async/debounce.ts
Download https://deno.land/std@0.113.0/async/deferred.ts
Download https://deno.land/std@0.113.0/async/delay.ts
Download https://deno.land/std@0.113.0/async/mux_async_iterator.ts
Download https://deno.land/std@0.113.0/async/pool.ts
Download https://deno.land/std@0.113.0/async/tee.ts
Download https://deno.land/std@0.113.0/node/_stream/buffer_list.ts
Download https://deno.land/std@0.113.0/node/_stream/from.ts
Download https://deno.land/std@0.113.0/fmt/colors.ts
Download https://deno.land/std@0.113.0/testing/_diff.ts
Download https://deno.land/std@0.113.0/fmt/printf.ts
Warning Implicitly using latest version (0.113.0) for https://deno.land/std/node/fs.ts
Download https://deno.land/std@0.113.0/node/fs.ts
Download https://cdn.skypack.dev/-/inherits@v2.0.3-wYiU4LJyCRMdE1au3xlt/dist=es2020,mode=imports/optimized/inherits.js
Download https://cdn.skypack.dev/-/setprototypeof@v1.1.1-Bua5IB5D1sNpAG2Wz80Y/dist=es2020,mode=imports/optimized/setprototypeof.js
Download https://cdn.skypack.dev/-/statuses@v2.0.0-n3zLoRGOEYGpxHYZaDtj/dist=es2020,mode=imports/optimized/statuses.js
Download https://cdn.skypack.dev/-/toidentifier@v1.0.0-H2o3PHtLHNj8LaXhft06/dist=es2020,mode=imports/optimized/toidentifier.js
Download https://deno.land/std@0.113.0/node/_util/_util_callbackify.ts
Download https://deno.land/std@0.113.0/node/_util/_util_promisify.ts
Download https://deno.land/std@0.113.0/node/_util/_util_types.ts
Download https://deno.land/std@0.113.0/_util/assert.ts
Download https://deno.land/std@0.113.0/node/internal_binding/uv.ts
Download https://deno.land/std@0.113.0/node/url.ts
Download https://cdn.skypack.dev/-/media-typer@v0.3.0-qwv2Y1RFXX2fRByvE8Ki/dist=es2020,mode=imports/optimized/media-typer.js
Download https://cdn.skypack.dev/-/mime-types@v2.1.29-gvGDpL2HWQnvfIm6WFh1/dist=es2020,mode=imports/optimized/mime-types.js
Download https://deno.land/std@0.113.0/io/buffer.ts
Download https://cdn.skypack.dev/-/unpipe@v1.0.0-GulchbcdwxpoNyFnZZek/dist=es2020,mode=imports/optimized/unpipe.js
Download https://deno.land/std@0.113.0/node/_fs/_fs_access.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_appendFile.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_chmod.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_chown.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_close.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_constants.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_copy.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_dir.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_dirent.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_exists.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_fdatasync.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_fstat.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_fsync.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_ftruncate.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_futimes.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_link.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_lstat.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_mkdir.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_mkdtemp.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_open.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_readFile.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_readdir.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_readlink.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_realpath.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_rename.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_rmdir.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_stat.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_symlink.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_truncate.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_unlink.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_utimes.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_watch.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_writeFile.ts
Download https://deno.land/std@0.113.0/node/fs/promises.ts
Download https://deno.land/std@0.113.0/_util/os.ts
Download https://deno.land/std@0.113.0/path/_constants.ts
Download https://deno.land/std@0.113.0/node/path.ts
Download https://deno.land/std@0.113.0/node/_fs/_fs_common.ts
Download https://cdn.skypack.dev/-/strtok3@v6.2.4-5FePyU4JO1AsJEam2V6Y/dist=es2020,mode=imports/unoptimized/lib/AbstractTokenizer.js
Download https://deno.land/std@0.113.0/fs/exists.ts
Download https://deno.land/std@0.113.0/bytes/bytes_list.ts
Download https://deno.land/std@0.113.0/bytes/mod.ts
Download https://deno.land/std@0.113.0/io/types.d.ts
Download https://deno.land/std@0.113.0/path/mod.ts
Download https://cdn.skypack.dev/-/mime-db@v1.46.0-L2W401BIEgSDjYqKoZks/dist=es2020,mode=imports/optimized/mime-db.js
Download https://deno.land/std@0.113.0/bytes/equals.ts
Download https://deno.land/std@0.113.0/path/_interface.ts
Download https://deno.land/std@0.113.0/path/common.ts
Download https://deno.land/std@0.113.0/path/glob.ts
Download https://deno.land/std@0.113.0/path/posix.ts
Download https://deno.land/std@0.113.0/path/separator.ts
Download https://deno.land/std@0.113.0/path/win32.ts
Download https://deno.land/std@0.113.0/path/_util.ts
Check file:///Users/mitsu/ghq/github.com/mitsuoka0423/line-bot-sample-deno/index.ts
error: TS2339 [ERROR]: Property 'futime' does not exist on type 'typeof Deno'. 'Deno.futime' is an unstable API. Did you forget to run with the '--unstable' flag?
Deno.futime(fd, atime, mtime).then(() => callback(null), callback);
~~~~~~
at https://deno.land/std@0.113.0/node/_fs/_fs_futimes.ts:37:8
TS2339 [ERROR]: Property 'futimeSync' does not exist on type 'typeof Deno'. 'Deno.futimeSync' is an unstable API. Did you forget to run with the '--unstable' flag?
Deno.futimeSync(fd, atime, mtime);
~~~~~~~~~~
at https://deno.land/std@0.113.0/node/_fs/_fs_futimes.ts:48:8
TS2339 [ERROR]: Property 'utime' does not exist on type 'typeof Deno'. 'Deno.utime' is an unstable API. Did you forget to run with the '--unstable' flag?
Deno.utime(path, atime, mtime).then(() => callback(null), callback);
~~~~~
at https://deno.land/std@0.113.0/node/_fs/_fs_utimes.ts:40:8
TS2339 [ERROR]: Property 'utimeSync' does not exist on type 'typeof Deno'. 'Deno.utimeSync' is an unstable API. Did you forget to run with the '--unstable' flag?
Deno.utimeSync(path, atime, mtime);
~~~~~~~~~
at https://deno.land/std@0.113.0/node/_fs/_fs_utimes.ts:52:8
Found 4 errors.
--unstable
フラグをつけて再実行してみる。
deno run index.ts --unstable
お、エラーなくなった!
簡単にブロードキャストメッセージのコード作成して実験。
index.ts
import line from 'https://cdn.skypack.dev/@line/bot-sdk';
const config = {
channelSecret: 'チャンネルシークレット',
channelAccessToken: 'チャンネルアクセストークン'
};
const client = new line.Client(config);
try {
const res = await client.broadcast([{
type: 'text',
text: 'ブロードキャストします'
}]);
console.log(res);
} catch (error) {
console.log(`エラー: ${error.statusMessage}`);
console.log(error.originalError.response.data);
}
deno run index.ts --unstable
~/g/g/m/line-bot-sample-deno ❯❯❯ (master →☡) deno run index.ts --unstable
error: Uncaught Error: [Package Error] "node:fs" does not exist. (Imported by "strtok3").
throw new Error("[Package Error] \"node:fs\" does not exist. (Imported by \"strtok3\").");
^
at https://cdn.skypack.dev/error/node:node:fs?from=strtok3:14:7
node:fsが存在しないとエラー。