【问题标题】:exception while importing module in ember js在ember js中导入模块时出现异常
【发布时间】:2015-04-16 10:47:02
【问题描述】:

我需要从 emberjs 应用程序中的字符串中删除变音符号。 我为此找到了一个插件:fold-to-ascii 但我不知道如何在我的应用中使用它。

我通过 npm 添加了这个插件,它在我的应用程序的 node_modules 文件夹下可见

在文档中这个插件的用法是:

var foldToAscii = require("fold-to-ascii");
foldToAscii.fold("★Lorém ïpsum dölor.")

但我得到一个例外:

Uncaught Error: Could not find module fold-to-ascii

还尝试像@Kori John Roys 建议的那样导入它:

import foldToAscii from 'fold-to-ascii'

但它只给了我新的例外:

Error while processing route: transports.index Could not find module fold-to-ascii imported from test-ember/pods/transport/model

我做错了什么?

【问题讨论】:

    标签: javascript ember.js plugins npm require


    【解决方案1】:

    假设您使用的是 ember-cli:

    npm install --save-dev ember-browserify
    

    然后你可以像这样导入:

    import foldToAscii from "npm:fold-to-ascii"
    

    【讨论】:

    • 试过了,现在我得到错误:处理路由时出错:transports.index 找不到模块fold-to-asciitest-ember/pods/transport/model导入错误:找不到模块fold-to-asciitest-ember/pods/transport/model导入,我应该将导入指向 node_modules 文件夹吗?
    • 啊,是的,你说得对,对不起。你会想npm install --save-dev ember-browserify,然后import foldToAscii from "npm:fold-to-ascii"
    猜你喜欢
    • 2022-08-10
    • 1970-01-01
    • 2015-07-04
    • 2021-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-22
    相关资源
    最近更新 更多