Giter Site home page Giter Site logo

Comments (7)

plh97 avatar plh97 commented on June 7, 2024

我的天,各种url 绕来绕去

from blog.

ahuigo avatar ahuigo commented on June 7, 2024
  1. 最后那段通用loader.mjs 少了一个默认参数: const baseURL = new URL('file://'); parentModuleURL=baseURL;
  2. node 交互模式/chrome 交互模式还不支持 import, 如果支持了 调试会很方便,imort 推广起来更容易
  3. 希望node 能默认支持这个loader.mjs, 这样就能无通升级、无痛使用了

from blog.

zy445566 avatar zy445566 commented on June 7, 2024

👍

from blog.

kongling94 avatar kongling94 commented on June 7, 2024

我记得koa2现阶段是不支持import引入的又或者是在inexjs启动文件中不支持。

from blog.

ahuigo avatar ahuigo commented on June 7, 2024

我记得koa2现阶段是不支持import引入的又或者是在inexjs启动文件中不支持。

不是koa2 不支持import,而是你的node 需要开启这个支持才行。

from blog.

xiaohuaxiangwoyiyang avatar xiaohuaxiangwoyiyang commented on June 7, 2024

这个运行之后不会报错吗
≥ node --experimental-modules --loader ./custom-loader.mjs server/index.js 14:45
(node:73405) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use node --trace-warnings ... to show where the warning was created)
internal/process/esm_loader.js:74
internalBinding('errors').triggerUncaughtException(
^

TypeError [ERR_INVALID_URL]: Invalid URL: [object Object]
at onParseError (internal/url.js:257:9)
at new URL (internal/url.js:333:5)
at new URL (internal/url.js:330:22)
at resolve (file:///Users/huahua/Desktop/scripts/custom-loader.mjs:49:20)
at Loader.resolve (internal/modules/esm/loader.js:85:40)
at Loader.getModuleJob (internal/modules/esm/loader.js:229:28)
at Loader.import (internal/modules/esm/loader.js:164:28)
at internal/modules/run_main.js:46:28
at Object.loadESM (internal/process/esm_loader.js:68:11) {
input: '[object Object]',
code: 'ERR_INVALID_URL'

from blog.

chenshenhai avatar chenshenhai commented on June 7, 2024

@xiaohuaxiangwoyiyang 您好,这个文章是3年前写的,Node已经支持原生ES module使用了,不需要原来实验中的方法哈。
您提供的这个报错里就有这个提示哈

ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.