Angular2 Cli 项目中的 PouchDB 身份验证库
PouchDB Authentication library in Angular2 Cli project
我在将 PouchDB 身份验证库 (https://github.com/nolanlawson/pouchdb-authentication) 导入我的 Angular2 Cli Typescript 项目时遇到问题。
我已将此添加到我的打字中:
declare module "pouchdb-authentication" {}
我的 system-config.ts
文件包含在 map
:
'pouchdb-authentication': 'vendor/pouchdb-authentication/dist/',
并在 packages
中:
"pouchdb-authentication": {
main: "pouchdb.authentication.js",
defaultExtension: "js"
},
我正在尝试这样使用它:
PouchDB.plugin(require('pouchdb-authentication'));
我也试过:
import * as PouchDBAuthentication from 'pouchdb-authentication';
目前,我在控制台中遇到此错误:
zone.js:461: Unhandled Promise rejection: (SystemJS) TypeError: AMD module http://localhost:4200/vendor/pouchdb-authentication/dist/pouchdb.authentication.js did not define
如有任何想法,我们将不胜感激!谢谢!
您确定要引入 dist/pouchdb.authentication.js
而不是使用 CommonJS 包吗? dist/
包含 UMD 包,在这种情况下,SystemJS 似乎正在尝试将其加载为 AMD。
编辑:没关系,我看到我忘了将它构建为 UMD。我会解决这个问题,然后你应该能够很好地使用 dist/
(不过,我认为你不需要这样做,因为 SystemJS 应该能够很好地使用 CommonJS)。
在这里打开了一个问题:https://github.com/nolanlawson/pouchdb-authentication/issues/103
编辑: 已在 pouchdb-authentication 0.5.2 中修复,请重试
我在将 PouchDB 身份验证库 (https://github.com/nolanlawson/pouchdb-authentication) 导入我的 Angular2 Cli Typescript 项目时遇到问题。
我已将此添加到我的打字中:
declare module "pouchdb-authentication" {}
我的 system-config.ts
文件包含在 map
:
'pouchdb-authentication': 'vendor/pouchdb-authentication/dist/',
并在 packages
中:
"pouchdb-authentication": {
main: "pouchdb.authentication.js",
defaultExtension: "js"
},
我正在尝试这样使用它:
PouchDB.plugin(require('pouchdb-authentication'));
我也试过:
import * as PouchDBAuthentication from 'pouchdb-authentication';
目前,我在控制台中遇到此错误:
zone.js:461: Unhandled Promise rejection: (SystemJS) TypeError: AMD module http://localhost:4200/vendor/pouchdb-authentication/dist/pouchdb.authentication.js did not define
如有任何想法,我们将不胜感激!谢谢!
您确定要引入 dist/pouchdb.authentication.js
而不是使用 CommonJS 包吗? dist/
包含 UMD 包,在这种情况下,SystemJS 似乎正在尝试将其加载为 AMD。
编辑:没关系,我看到我忘了将它构建为 UMD。我会解决这个问题,然后你应该能够很好地使用 dist/
(不过,我认为你不需要这样做,因为 SystemJS 应该能够很好地使用 CommonJS)。
在这里打开了一个问题:https://github.com/nolanlawson/pouchdb-authentication/issues/103
编辑: 已在 pouchdb-authentication 0.5.2 中修复,请重试