2016-06-21 58 views
3

我也試圖按照教程,這似乎是使用pouchdb與Angular 2/Ionic 2的一個很好的切入點。我的OS是OSxTypescript找不到'require',用Ionic2設置pouchdb

越來越能夠安裝分型後「需要」 ionic serve拋出:

TypeScript error: (...) Error TS2304: Cannot find name 'require'.

我跟着installing typings require failed in macOSXInstall Typings require for Ionic2 application線程,但它並沒有幫助我。 (更好地理解 '打字稿' 的旁邊)

的需要的文件是在:

/ionic2-tutorial-pouchdb/typings/globals/require 

什麼想法?關於'安裝要求'的教程不適用於我。

THX皮特

+0

感謝@ devid-farinelli改善我的帖子...... – pdewaard

回答

0

我猜測,你有一個像一行代碼:

let PouchDB = require('pouchdb'); 

你並不需要使用需要導入到Angular2。相反,你應該使用進口這樣的:

import PouchDB from 'pouchdb'; 

Reference from one of the GitHub issues on the PouchDB GitHub account

您所提供的鏈接也使用進口,而不是要求。在更新版本的打字稿中,類型已被@Types取代。