Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: The requested module 'ocpp-eliftech' does not provide an export named 'OCPPServer' #8

Open
udayprksh opened this issue Mar 25, 2020 · 14 comments

Comments

@udayprksh
Copy link

Hi,

I have installed the OCPP module using "npm install --save ocpp-eliftech" and use the OCPP Server example in our index.js file as shown below :

import { OCPPServer, OCPPCommands } from 'ocpp-eliftech';
const server = new OCPPServer();
server.listen(9220);
server.onRequest = async function(command) {
// Handle different commands
if (command instanceof OCPPCommands.BootNotification) {
return {
status: 'Accepted',
currentTime: new Date().toISOString(),
interval: 60
};
}
}

When we run npm start then got error "SyntaxError: The requested module 'ocpp-eliftech' does not provide an export named 'OCPPServer'"

Please let me know how to solve this issue.

@nagess-abdollahi
Copy link

hi
I also received this error.Is your problem solved?

@psnehanshu
Copy link

psnehanshu commented Jun 23, 2020

Try this

import { CentralSystem, OCPPCommands } from 'ocpp-eliftech';

const server = new CentralSystem();
server.listen(9220);

@nagess-abdollahi
Copy link

i try this but get this error SyntaxError: The requested module 'ocpp-eliftech' does not provide an export named 'OCPPCommands'

@kvext
Copy link

kvext commented May 11, 2022

Hi @psnehanshu ,

I am facing the same issue for "OCPPCommands" and shows me error SyntaxError: The requested module 'ocpp-eliftech' does not provide an export named 'OCPPCommands'

So, can you please provide me the solution for it?

@psnehanshu
Copy link

psnehanshu commented May 11, 2022

I wrote a small project using this package but got this error instead

Error: Cannot find module 'babel-runtime/helpers/extends'

Hence I installed it using npm i babel-runtime.

But then it worked. Check the attached zip file.

ocpp-eliftech.zip

Also do notice that I have put type: module in package.json.

I will also like to plug my own package here, which you can give a try. https://github.com/pSnehanshu/ocpp-task-manager

@kvext
Copy link

kvext commented May 12, 2022

Hi @psnehanshu,

I have downloaded "ocpp-eliftech.zip" and extract and tried to run on my end as below:

on package.json file I have added "start": "node index.js", under "scripts" object and run with command "npm start".

But still facing the same issue and show me error:
SyntaxError: The requested module 'ocpp-eliftech' does not provide an export named 'OCPPCommands'

Can you please point out to me why it is showing above error to me?

@psnehanshu
Copy link

What is your node version? Can you try with v16?

@kvext
Copy link

kvext commented May 12, 2022

Hi @psnehanshu ,
Thanks Awesome! now it's working with node version to 16.14.2
I think ocpp-eliftech package is working with ocpp version 1.6. Am I Correct?

@kvext
Copy link

kvext commented May 12, 2022

Hi @psnehanshu,

If we want to communicate with OCPP system in real world, then do we need to implement both server and client on our end? Or do we need to just implement OCPP client only?

Here, I am little bit confused because on some packages it is mentioned the server URL to config at client side like "http://localhost:9220/webServices/ocpp/CP1111" and on some packages it is mentioned as "ws://localhost:8080/ocpp/1.6J"

Because I have tried to run ocpp client, but not working on my end.
So, can you please provide me related help on it?

Thanks,

@psnehanshu
Copy link

@kvext Depends on if you are trying to build a charger or a backend system. Read my article and see if it helps. https://www.snehanshu.com/electric-vehicles/ocpp/2020/04/03/what-is-ocpp.html

@kvext
Copy link

kvext commented May 12, 2022

Hi @psnehanshu,
I want to communicate with charging station through back-end and want to get status and information about charging % to be completed.
So, what should I do for it?
Thanks,

@psnehanshu
Copy link

You will have to create an OCPP server. It will listen for websocket connections. It can receive commands from charger as well as send commands to the charger. I will suggest you read the official documentation for a better understanding.

@kvext
Copy link

kvext commented Jun 1, 2022

Hi @psnehanshu,

I am trying to create OCPP server and client using https://www.npmjs.com/package/ocpp-rpc
But here, If I am sending message from server to client by creating separate apps like server_app and client_app, It is not working.
From server app, I want to send message or call method from server:

rpcServer.on('client', client => {
    client.call('Say', `Hello, ${client.identity}!`);
});

On Client app, I have already define method as below:

cli.handle('Say', ({params}) => {
    console.log('Server said:', params);
});

But, Same thing is working only if I will create both server and client objects on the same file as per last example.

So, Any idea why it is not working if I want to call methods with separate files?

Thanks,

@psnehanshu
Copy link

You should ask the creator of that library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants