exception while importing module in ember js

2019-08-09 23:55发布

I need to remove diacritics from string in emberjs app. I found a plugin for this: fold-to-ascii but I don't know how to use it in my app.

I added this plugin via npm and it is visible under node_modules folder in my app

In docs usage of this plugin is:

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

but i get an exception:

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

also tried importing it like @Kori John Roys suggested:

import foldToAscii from 'fold-to-ascii'

but it gives me only new exception:

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

What am I doing wrong ?

1条回答
等我变得足够好
2楼-- · 2019-08-10 00:17

Assuming you are using ember-cli:

npm install --save-dev ember-browserify

then you can import like this:

import foldToAscii from "npm:fold-to-ascii"
查看更多
登录 后发表回答