我在使用ember-cli应用程序导入节点模块时遇到了一些问题。 在我的notebook / route.js中,我有
import Ember from 'ember';
import EventSource from 'eventsource';
我看到其他文件导入其他节点模块,例如' ember-data'这条路。 但是,当我导航到该路径时,我在控制台中得到以下内容:
Error: Could not find module `eventsource` imported from `ui/notebooks/route`
at requireFrom (loader.js:110)
at reify (loader.js:97)
at mod.state (loader.js:140)
at tryFinally (loader.js:21)
at requireModule (loader.js:139)
at Ember.DefaultResolver.extend._extractDefaultExport (ember-resolver.js:390)
at resolveOther (ember-resolver.js:122)
at superWrapper (ember.debug.js:21571)
at exports.default._emberRuntimeSystemObject.default.extend.resolveRoute (ember.debug.js:5014)
at exports.default._emberRuntimeSystemObject.default.extend.resolve (ember.debug.js:4847)
我使用npm install eventsource --save安装了节点模块,它在我的package.json中生成了以下内容:
"devDependencies": {
"body-parser": "^1.14.1",
"broccoli-asset-rev": "^2.1.2",
"ember-cli": "1.13.8",
"ember-cli-app-version": "1.0.0",
"ember-cli-babel": "^5.1.3",
"ember-cli-dependency-checker": "^1.0.1",
"ember-cli-htmlbars": "1.0.1",
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
"ember-cli-ic-ajax": "0.2.1",
"ember-cli-inject-live-reload": "^1.3.1",
"ember-cli-qunit": "^1.0.0",
"ember-cli-rails-addon": "0.0.12",
"ember-cli-release": "0.2.3",
"ember-cli-showdown": "2.5.0",
"ember-cli-sri": "^1.0.3",
"ember-cli-uglify": "^1.2.0",
"ember-data": "2.1.0",
"ember-disable-proxy-controllers": "^1.0.0",
"ember-export-application-global": "^1.0.3",
"express": "^4.13.3",
"glob": "^4.5.3",
"morgan": "^1.6.1",
"nedb": "^1.2.1"
},
"dependencies": {
"eventsource": "^0.1.6"
}
它似乎是一个有效的节点包,来源here:
有人能帮忙解释一下吗?新的ember和节点,但不是Javascript ...我是铁路开发人员。
谢谢!
答案 0 :(得分:3)
您不能将每个npm模块导入Ember CLI应用程序,因为它是npm模块。
您只能使用带有特殊npm包的import关键字 - Ember CLI插件,它会为您的应用程序公开一些公共API。