0

clicke here to see pondjs folder inside node-modulesI've installed pondjs(https://www.npmjs.com/package/pondjs) using npm install pondjs --save in my react application. It's also present in package.json. I couldn't understand why in App. js when I'm doing :

import { TimeSeries , TimeRange} from 'pondjs';

it says module not installed and hence unable to recognise it's functions.

Also, I have a js file which contains lots of data in Object form and I'm trying to import that file in App.js using :

import pathtofile/inputdata.js';

and storing in the variable as below :

var input_data = data;

IS this the right way to do in react App.js file? Please suggest

3 Answers 3

2

As there are 2 parts to your question. I will answer them in order.

Your first question was you weren't able to call the methods of pondjs even though you installed it.

For that make sure that there is your pondjs folder inside the node_modules folder that will be created when you install some packages in your repository.

EDIT :

Are you only having issues with pondjs or are you facing issues with all packages?

If you can find the installed package in node_modules folder and is facing the same issue for all packages, upgrade npm. Your problem is that it doesn't search in the right folder. Try upgrading npm so that it places files in the right spots.

If it's only for pondjs issue might be with the package rather that with your npm package. Make sure you read documentation right and are doing in the right way.


Coming to your second problem.

Export the variable you want to access in the other file.

var obj = {
    a : [1, 2, 3, 4],
    b : { c : 'Hello World!' }
}

export var obj;

And call it like,

import { obj } from './path/to/the/file.js'

Sign up to request clarification or add additional context in comments.

7 Comments

I have added a picture which shows pondjs is present inside node-modules.
in my app.js file, i can do something like this? var k = obj.a;
yes, you can. once you import it into another file, it's just same as a variable you declared in that file.
any advice on pondjs thing?
var obj = { a : [1, 2, 3, 4], b : { c : 'Hello World!' } } export var obj; if i do something like this, so when you hover on var obj it says duplicate declaration. Is it because while exporting your are again specifying var, so its creating a new variable.
|
0

For pondjs, my code is working on Sumblime Text and Terminal. May be Webstorm IDE is not recognizing Pondjs or something.

Comments

0

Use require instead of import.

const { TimeSeries, TimeRange } = require('pondjs');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.