rosnodejs.initNode is not a function
CursedCat7 opened this issue · comments
I am currently using ROS Noetic and trying to set up a simple control web server using Node.js version 16. However, I am encountering the following error with the rosnodejs library that I have been using successfully.
Even when I try to demonstrate with the example code provided, I still encounter the same error. I have tried uninstalling and reinstalling the node module, but the issue persists. What could be the problem?
const rosnodejs = require('rosnodejs');
rosnodejs.initNode('/my_node')
.then(() => {
// do stuff
});
>on console
rosnodejs.initNode('/my_node')
^
TypeError: rosnodejs.initNode is not a function
at Object.<anonymous> (/home/ME/Desktop/ros-web-server/test.js:2:11)
at Module._compile (node:internal/modules/cjs/loader:1198:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
at Module.load (node:internal/modules/cjs/loader:1076:32)
at Function.Module._load (node:internal/modules/cjs/loader:911:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:22:47
``` `
That's bizarre. Can you console.log(rosodejs)
and post the result here? Also, please post the result of npm ls rosnodejs
in the project folder.
That's bizarre. Can you
console.log(rosodejs)
and post the result here? Also, please post the result ofnpm ls rosnodejs
in the project folder.
ok.
const rosnodejs = require('rosnodejs');
console.log(rosnodejs)
=> { node: [Function: node], types: [Function (anonymous)] }
and npm ls rosnodejs
=> ros-web-server@1.0.0 /#MyPath#/ros-web-server
└── rosnodejs@0.1.1
thx for reply.
Your rosnodejs version is ancient! The current version is 3.0.2. You must be doing something wrong when installing it. Try forcing it using npm i rosnodejs@latest
.