Install Typings require for Ionic2 application

微笑、不失礼 提交于 2019-12-02 04:47:56

问题


So I am working on Ionice2 project (still new at this .. almost a week), and I am trying to follow the tutorial below to use PouchDB for LocalStorage.

Tutorial: http://gonehybrid.com/how-to-use-pouchdb-sqlite-for-local-storage-in-ionic-2/

One of the requirements is to install require using the following command

typings install require --ambient --save

Whenever I try this command, I get the error

Unable to find "require" ("npm") in the registry. 
Did you want to try searching another source? 
Also, if you want contribute these typings, please help us: https://github.com/typings/registry

Noting that I already installed Typings using the command below, what are the possible causes for this issue ?

npm install typings --global

回答1:


Typings has been updated recently. Update to latest version of typings first.

To install require.d.ts file use typings install dt~require --save --global

Refer https://github.com/typings/typings for further details




回答2:


Not a direct answer to the question, but I think it should be mentioned. The Typescript team has recently added a built in way of managing definition files. They've built the @types system on top of npm. The whole goal is that you don't need to use two separate package managers and you don't need to use multiple config files (previously package.json, typings.json, etc). Now, it's all managed within package.json.

If you were to install lodash, for example. You just:

npm install --save lodash
npm install --save @types/lodash

And you're good to go. Both are managed in your package.json and you won't need to use any /// <reference-path path="blah-blah-blah">.

Or, as Microsoft calls it, "The Future of Declaration Files".



来源:https://stackoverflow.com/questions/37444238/install-typings-require-for-ionic2-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!