Wednesday, October 19, 2016

Using Typings' global option with npm run

 In my Angular 2 project using Typescript, I wanted to install typing definitions for OpenLayers. Seems the best way to do this is through Typings Definition Manager (npm install typings). So I run this via npm run typings install dt~openlayers and keep getting the following error:
Attempted to compile "openlayers" as an external module, but it looks like a global module. You'll need to enable the global option to continue.
Easy enough, I'll use the global option!

npm run typings install --global --save dt~openlayers

Nope! Same error! Why?!

Turns out, through npm run, it's trying to parse those options for itself. So to pass the options to typings instead, do this:

npm run typings install -- --global --save dt~openlayers
Note the extra "--" in there!

No comments:

Post a Comment