Headroom.js with Typescript can't find the module
Anyone got this working in Typescript land? Googling around and it appears not.
Tying to incorporate this library into my Browserify project without any luck.
I have this typings file for v0.9.3 of headroom.js
- https://github.com/retyped/headroom-tsd-ambient/blob/master/headroom.d.ts
- node module installed as
node_modules/headroom.js/(yes it's a folder; I have never seen a node module named this way before.) - headroom.js's main entry as per package.json is
node_modules/headroom.js/dist/headroom.js
When I try to import the module into my app, it can't be found.
{ [TypeScript error: resources/assets/typescript/app.ts(12,24): Error TS2307: Cannot find module 'headroom.js'.]
message: 'resources/assets/typescript/app.ts(12,24): Error TS2307: Cannot find module 'headroom.js'.',
fileName: 'resources/assets/typescript/app.ts',
line: 12,
column: 24,
name: 'TypeScript error' }
Have tried all these permutations:
import {Headroom} from "headroom.js"; //nope
import {Headroom} from "headroom.js"; //nope
import {Headroom} from "Headroom.js"; //nope
import {Headroom} from "headroomjs"; //nope
import {Headroom} from "headroomjs"; //nope
import {Headroom} from "headroom"; //nope
import {Headroom} from "Headroom"; //nope
import * as headroom from "headroom.js"; // nope
The typings file is definitely being imported as used correctly.
IDE is saying that it can find the directory:

What am I doing wrong?
Edit 13-08-2015
1.
app.ts pulls in the typings from the typings dir like this:
/// <reference path="../../../typings/index.d.ts" />
index.d.tscontains these typings
/// <reference path="bootstrap/bootstrap.d.ts" />
/// <reference path="custom.d.ts" />
/// ..etc...
/// <reference path="Headroom/headroom.d.ts" />
It's definitely there.

typescript browserify headroom.js
add a comment |
Anyone got this working in Typescript land? Googling around and it appears not.
Tying to incorporate this library into my Browserify project without any luck.
I have this typings file for v0.9.3 of headroom.js
- https://github.com/retyped/headroom-tsd-ambient/blob/master/headroom.d.ts
- node module installed as
node_modules/headroom.js/(yes it's a folder; I have never seen a node module named this way before.) - headroom.js's main entry as per package.json is
node_modules/headroom.js/dist/headroom.js
When I try to import the module into my app, it can't be found.
{ [TypeScript error: resources/assets/typescript/app.ts(12,24): Error TS2307: Cannot find module 'headroom.js'.]
message: 'resources/assets/typescript/app.ts(12,24): Error TS2307: Cannot find module 'headroom.js'.',
fileName: 'resources/assets/typescript/app.ts',
line: 12,
column: 24,
name: 'TypeScript error' }
Have tried all these permutations:
import {Headroom} from "headroom.js"; //nope
import {Headroom} from "headroom.js"; //nope
import {Headroom} from "Headroom.js"; //nope
import {Headroom} from "headroomjs"; //nope
import {Headroom} from "headroomjs"; //nope
import {Headroom} from "headroom"; //nope
import {Headroom} from "Headroom"; //nope
import * as headroom from "headroom.js"; // nope
The typings file is definitely being imported as used correctly.
IDE is saying that it can find the directory:

What am I doing wrong?
Edit 13-08-2015
1.
app.ts pulls in the typings from the typings dir like this:
/// <reference path="../../../typings/index.d.ts" />
index.d.tscontains these typings
/// <reference path="bootstrap/bootstrap.d.ts" />
/// <reference path="custom.d.ts" />
/// ..etc...
/// <reference path="Headroom/headroom.d.ts" />
It's definitely there.

typescript browserify headroom.js
add a comment |
Anyone got this working in Typescript land? Googling around and it appears not.
Tying to incorporate this library into my Browserify project without any luck.
I have this typings file for v0.9.3 of headroom.js
- https://github.com/retyped/headroom-tsd-ambient/blob/master/headroom.d.ts
- node module installed as
node_modules/headroom.js/(yes it's a folder; I have never seen a node module named this way before.) - headroom.js's main entry as per package.json is
node_modules/headroom.js/dist/headroom.js
When I try to import the module into my app, it can't be found.
{ [TypeScript error: resources/assets/typescript/app.ts(12,24): Error TS2307: Cannot find module 'headroom.js'.]
message: 'resources/assets/typescript/app.ts(12,24): Error TS2307: Cannot find module 'headroom.js'.',
fileName: 'resources/assets/typescript/app.ts',
line: 12,
column: 24,
name: 'TypeScript error' }
Have tried all these permutations:
import {Headroom} from "headroom.js"; //nope
import {Headroom} from "headroom.js"; //nope
import {Headroom} from "Headroom.js"; //nope
import {Headroom} from "headroomjs"; //nope
import {Headroom} from "headroomjs"; //nope
import {Headroom} from "headroom"; //nope
import {Headroom} from "Headroom"; //nope
import * as headroom from "headroom.js"; // nope
The typings file is definitely being imported as used correctly.
IDE is saying that it can find the directory:

What am I doing wrong?
Edit 13-08-2015
1.
app.ts pulls in the typings from the typings dir like this:
/// <reference path="../../../typings/index.d.ts" />
index.d.tscontains these typings
/// <reference path="bootstrap/bootstrap.d.ts" />
/// <reference path="custom.d.ts" />
/// ..etc...
/// <reference path="Headroom/headroom.d.ts" />
It's definitely there.

typescript browserify headroom.js
Anyone got this working in Typescript land? Googling around and it appears not.
Tying to incorporate this library into my Browserify project without any luck.
I have this typings file for v0.9.3 of headroom.js
- https://github.com/retyped/headroom-tsd-ambient/blob/master/headroom.d.ts
- node module installed as
node_modules/headroom.js/(yes it's a folder; I have never seen a node module named this way before.) - headroom.js's main entry as per package.json is
node_modules/headroom.js/dist/headroom.js
When I try to import the module into my app, it can't be found.
{ [TypeScript error: resources/assets/typescript/app.ts(12,24): Error TS2307: Cannot find module 'headroom.js'.]
message: 'resources/assets/typescript/app.ts(12,24): Error TS2307: Cannot find module 'headroom.js'.',
fileName: 'resources/assets/typescript/app.ts',
line: 12,
column: 24,
name: 'TypeScript error' }
Have tried all these permutations:
import {Headroom} from "headroom.js"; //nope
import {Headroom} from "headroom.js"; //nope
import {Headroom} from "Headroom.js"; //nope
import {Headroom} from "headroomjs"; //nope
import {Headroom} from "headroomjs"; //nope
import {Headroom} from "headroom"; //nope
import {Headroom} from "Headroom"; //nope
import * as headroom from "headroom.js"; // nope
The typings file is definitely being imported as used correctly.
IDE is saying that it can find the directory:

What am I doing wrong?
Edit 13-08-2015
1.
app.ts pulls in the typings from the typings dir like this:
/// <reference path="../../../typings/index.d.ts" />
index.d.tscontains these typings
/// <reference path="bootstrap/bootstrap.d.ts" />
/// <reference path="custom.d.ts" />
/// ..etc...
/// <reference path="Headroom/headroom.d.ts" />
It's definitely there.

typescript browserify headroom.js
typescript browserify headroom.js
edited Nov 21 '18 at 5:21
Cœur
18.9k9112154
18.9k9112154
asked Aug 12 '16 at 7:13
SimonSimon
62721739
62721739
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
A search for typings for Headroom.js:
typings search headroom
Finds one set of declarations that needs to be installed with this command:
typings install dt~headroom --global
The installation insists upon the --global option and that's the first hint at what's going on. The installed typings are global; they are not typings for a module (there is no module defined in the .d.ts). So TypeScript will not associate them with an imported or required module.
To use the installed typings, you will have to use require to import the module and will then need to set up a global that matches the class declared in the typings (you mentioned you're using Browserify, so you should be able to use global; window would also work):
global["Headroom"] = require("headroom.js");
let h = new Headroom(...); // TypeScript should use the typings here
Looking at dist/headroom.js, it's apparent that it can be consumed via AMD, CommonJS or plain JavaScript. To reflect that, I guess the author of the typings declarations for Headroom.js has made them global.
Thank you for your detailed answer.
– Simon
Aug 14 '16 at 22:54
add a comment |
Headroom does not include any typings. That's why TypeScript can not find "the directory". You can do two things:
(1) Add your own .d.ts file for headroom and make sure it is available on runtime.
(2) Use const Headroom = require('headroom.js'); to import it. Depending on your browserify configuration, it should include headroom when you build your project. Note that you will not have any typings for headroom.
We're using (2) with webpack and it works fine. When you're writing require('foo') webpack will try to find a npm package called "foo" and add it to your project. TypeScript is ok, with using require because it is defined in one of the included .d.ts files (node.js for example). But of course, you'll be missing the autocompletion features etc of TypeScript.
Thanks for you answer. I know I can just do arequirelike that. The typings file I am using (github.com/retyped/headroom-tsd-ambient/blob/master/…) ins't correct?
– Simon
Aug 13 '16 at 4:18
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f38912021%2fheadroom-js-with-typescript-cant-find-the-module%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
A search for typings for Headroom.js:
typings search headroom
Finds one set of declarations that needs to be installed with this command:
typings install dt~headroom --global
The installation insists upon the --global option and that's the first hint at what's going on. The installed typings are global; they are not typings for a module (there is no module defined in the .d.ts). So TypeScript will not associate them with an imported or required module.
To use the installed typings, you will have to use require to import the module and will then need to set up a global that matches the class declared in the typings (you mentioned you're using Browserify, so you should be able to use global; window would also work):
global["Headroom"] = require("headroom.js");
let h = new Headroom(...); // TypeScript should use the typings here
Looking at dist/headroom.js, it's apparent that it can be consumed via AMD, CommonJS or plain JavaScript. To reflect that, I guess the author of the typings declarations for Headroom.js has made them global.
Thank you for your detailed answer.
– Simon
Aug 14 '16 at 22:54
add a comment |
A search for typings for Headroom.js:
typings search headroom
Finds one set of declarations that needs to be installed with this command:
typings install dt~headroom --global
The installation insists upon the --global option and that's the first hint at what's going on. The installed typings are global; they are not typings for a module (there is no module defined in the .d.ts). So TypeScript will not associate them with an imported or required module.
To use the installed typings, you will have to use require to import the module and will then need to set up a global that matches the class declared in the typings (you mentioned you're using Browserify, so you should be able to use global; window would also work):
global["Headroom"] = require("headroom.js");
let h = new Headroom(...); // TypeScript should use the typings here
Looking at dist/headroom.js, it's apparent that it can be consumed via AMD, CommonJS or plain JavaScript. To reflect that, I guess the author of the typings declarations for Headroom.js has made them global.
Thank you for your detailed answer.
– Simon
Aug 14 '16 at 22:54
add a comment |
A search for typings for Headroom.js:
typings search headroom
Finds one set of declarations that needs to be installed with this command:
typings install dt~headroom --global
The installation insists upon the --global option and that's the first hint at what's going on. The installed typings are global; they are not typings for a module (there is no module defined in the .d.ts). So TypeScript will not associate them with an imported or required module.
To use the installed typings, you will have to use require to import the module and will then need to set up a global that matches the class declared in the typings (you mentioned you're using Browserify, so you should be able to use global; window would also work):
global["Headroom"] = require("headroom.js");
let h = new Headroom(...); // TypeScript should use the typings here
Looking at dist/headroom.js, it's apparent that it can be consumed via AMD, CommonJS or plain JavaScript. To reflect that, I guess the author of the typings declarations for Headroom.js has made them global.
A search for typings for Headroom.js:
typings search headroom
Finds one set of declarations that needs to be installed with this command:
typings install dt~headroom --global
The installation insists upon the --global option and that's the first hint at what's going on. The installed typings are global; they are not typings for a module (there is no module defined in the .d.ts). So TypeScript will not associate them with an imported or required module.
To use the installed typings, you will have to use require to import the module and will then need to set up a global that matches the class declared in the typings (you mentioned you're using Browserify, so you should be able to use global; window would also work):
global["Headroom"] = require("headroom.js");
let h = new Headroom(...); // TypeScript should use the typings here
Looking at dist/headroom.js, it's apparent that it can be consumed via AMD, CommonJS or plain JavaScript. To reflect that, I guess the author of the typings declarations for Headroom.js has made them global.
edited Aug 14 '16 at 23:29
answered Aug 13 '16 at 6:53
cartantcartant
37.6k786118
37.6k786118
Thank you for your detailed answer.
– Simon
Aug 14 '16 at 22:54
add a comment |
Thank you for your detailed answer.
– Simon
Aug 14 '16 at 22:54
Thank you for your detailed answer.
– Simon
Aug 14 '16 at 22:54
Thank you for your detailed answer.
– Simon
Aug 14 '16 at 22:54
add a comment |
Headroom does not include any typings. That's why TypeScript can not find "the directory". You can do two things:
(1) Add your own .d.ts file for headroom and make sure it is available on runtime.
(2) Use const Headroom = require('headroom.js'); to import it. Depending on your browserify configuration, it should include headroom when you build your project. Note that you will not have any typings for headroom.
We're using (2) with webpack and it works fine. When you're writing require('foo') webpack will try to find a npm package called "foo" and add it to your project. TypeScript is ok, with using require because it is defined in one of the included .d.ts files (node.js for example). But of course, you'll be missing the autocompletion features etc of TypeScript.
Thanks for you answer. I know I can just do arequirelike that. The typings file I am using (github.com/retyped/headroom-tsd-ambient/blob/master/…) ins't correct?
– Simon
Aug 13 '16 at 4:18
add a comment |
Headroom does not include any typings. That's why TypeScript can not find "the directory". You can do two things:
(1) Add your own .d.ts file for headroom and make sure it is available on runtime.
(2) Use const Headroom = require('headroom.js'); to import it. Depending on your browserify configuration, it should include headroom when you build your project. Note that you will not have any typings for headroom.
We're using (2) with webpack and it works fine. When you're writing require('foo') webpack will try to find a npm package called "foo" and add it to your project. TypeScript is ok, with using require because it is defined in one of the included .d.ts files (node.js for example). But of course, you'll be missing the autocompletion features etc of TypeScript.
Thanks for you answer. I know I can just do arequirelike that. The typings file I am using (github.com/retyped/headroom-tsd-ambient/blob/master/…) ins't correct?
– Simon
Aug 13 '16 at 4:18
add a comment |
Headroom does not include any typings. That's why TypeScript can not find "the directory". You can do two things:
(1) Add your own .d.ts file for headroom and make sure it is available on runtime.
(2) Use const Headroom = require('headroom.js'); to import it. Depending on your browserify configuration, it should include headroom when you build your project. Note that you will not have any typings for headroom.
We're using (2) with webpack and it works fine. When you're writing require('foo') webpack will try to find a npm package called "foo" and add it to your project. TypeScript is ok, with using require because it is defined in one of the included .d.ts files (node.js for example). But of course, you'll be missing the autocompletion features etc of TypeScript.
Headroom does not include any typings. That's why TypeScript can not find "the directory". You can do two things:
(1) Add your own .d.ts file for headroom and make sure it is available on runtime.
(2) Use const Headroom = require('headroom.js'); to import it. Depending on your browserify configuration, it should include headroom when you build your project. Note that you will not have any typings for headroom.
We're using (2) with webpack and it works fine. When you're writing require('foo') webpack will try to find a npm package called "foo" and add it to your project. TypeScript is ok, with using require because it is defined in one of the included .d.ts files (node.js for example). But of course, you'll be missing the autocompletion features etc of TypeScript.
answered Aug 12 '16 at 7:27
Sebastian SebaldSebastian Sebald
7,30833852
7,30833852
Thanks for you answer. I know I can just do arequirelike that. The typings file I am using (github.com/retyped/headroom-tsd-ambient/blob/master/…) ins't correct?
– Simon
Aug 13 '16 at 4:18
add a comment |
Thanks for you answer. I know I can just do arequirelike that. The typings file I am using (github.com/retyped/headroom-tsd-ambient/blob/master/…) ins't correct?
– Simon
Aug 13 '16 at 4:18
Thanks for you answer. I know I can just do a
require like that. The typings file I am using (github.com/retyped/headroom-tsd-ambient/blob/master/…) ins't correct?– Simon
Aug 13 '16 at 4:18
Thanks for you answer. I know I can just do a
require like that. The typings file I am using (github.com/retyped/headroom-tsd-ambient/blob/master/…) ins't correct?– Simon
Aug 13 '16 at 4:18
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f38912021%2fheadroom-js-with-typescript-cant-find-the-module%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown