Jason Tucker Jason Tucker - 10 days ago 5
Javascript Question

How to correct NodeJS Cannot find installed package?

Just went through the Hall of Heroes tutorial for Angular2 and was really enjoying the NPM system then I went to add my first package.

I added "eveonlinejs": "^2.0.0" to my package.json and ran "npm install"

The package installed and the folder is present in node_modules.

Running my server however results in.

app/eveapi.service.ts(2,29): error TS2307: Cannot find module 'eveonlinejs'.

The line in question is

import { eveonlinejs } from 'eveonlinejs';

From my research I believe that the import should hit the package.json in the "node_modules/eveonlinejs" directory and see the "main" property which is set.

I have tried deleting clearing the NPM cache and reinstalling the node_modules folder.

I have also tried using a require statement to point into the directory but then I get a missing module for "sax" which is installed inside the "eveonlinejs" directory.


First thing you should do is remove the {} around your import.

import { eveonlinejs } from 'eveonlinejs';
// ----^-------------^-------------------- Remove the curly braces

You probably want this

import eveonlinejs from 'eveonlinejs';

The reason is because wrapping {} around the import tries to extract a named export from the file, but you want the whole library.

// import { eveonlinejs } from 'eveonlinejs' expects export code as
export {

When you leave out the braces, the import tries to extract the default export.

// import eveonlinejs from 'eveonlinejs' expects import as
export default eveonlinejs

Now, if you're using the version of eveonlinejs that's is currently on github, this might not work depending on how you're transpiling your modules (and how this process deals with module.exports).

The safe way would be to just use require:

var eveonlinejs = require('eveonlinejs');