question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to use instamancer in Angular CLI project

See original GitHub issue

I am trying to use instamancer as part of an Angular project. When I try to compile angular and run the website with the instamancer node module, it gives me the below error:

ERROR in ./node_modules/instamancer/src/api/api.ts Module build failed (from ./node_modules/@ngtools/webpack/src/index.js): Error: /Volumes/SD_CACHE/PHPStorm/dmsolutions-angular/node_modules/instamancer/src/api/api.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv). at AngularCompilerPlugin.getCompiledFile (/Volumes/SD_CACHE/PHPStorm/dmsolutions-angular/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:912:23) at plugin.done.then (/Volumes/SD_CACHE/PHPStorm/dmsolutions-angular/node_modules/@ngtools/webpack/src/loader.js:41:31) at process._tickCallback (internal/process/next_tick.js:68:7)

I tried editing my tsconfig.json like the error recommended, but it remains unresolved as it asks me to include more and more files from Instamancer, which results in more errors reported.

My machine information:

  • OS: MacOS 10.11 El Capitan
  • Instamancer version 1.4.2
  • Node version 10.16.2
  • NPM version 6.10.3
  • Angular CLI: 8.2.2
  • Angular: 8.2.2

To reproduce this error, I tried replicating the ES2018 Typescript example in an angular service, but it is unable to compile with “ng build”.

Is Instamancer incompatible with Angular?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bwyyoungcommented, Aug 29, 2019

Ok Sir. Thank you. I will try it.

0reactions
ScriptSmithcommented, Aug 29, 2019

Here’s a quick example:

const express = require('express')
const app = express()
const port = 3000
const instamancer = require('instamancer')

async function getPosts(tag) {
    const hashtag = instamancer.hashtag(tag, {total: 5, silent: true});
    const posts = [];

    for await (const post of hashtag) {
        posts.push(post);
    }

    return posts;
}

let cachedPosts = []

async function getCached() {
    cachedPosts = await getPosts("puppies");
}
setTimeout(getCached, 3000)

app.get('/cached', async (req, res) => {
    res.send(JSON.stringify(cachedPosts));
})

app.get('/live', async (req, res) => {
    const posts = await getPosts(req.params["tag"]);
    res.send(JSON.stringify(posts));
})

app.listen(port, () => console.log(`Example app listening on port ${port}!`))

Visiting localhost:3000/cached will return a list of posts that’s updated once every 5 minutes, and visiting localhost:3000/live?tag=your_tag_here will fetch them on-demand.

You have to wait 30-seconds to a minute for the cached posts to appear, and you’ll have to wait about as long for something to be returned on the live endpoint. That should get you started.

Read more comments on GitHub >

github_iconTop Results From Across the Web

unable to resolve dependency tree error for creating new ...
Open the folder you create with ng new and open the package.json file. In devDependencies change the version of "jasmine-core" 3.6.0 to ...
Read more >
4 | How to create a Crowd sensing Application using Generic ...
First of all, create 2 new devices, copy the access token and insert it in the Javascript code respectively for edge and cloud...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found