Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Node.JS Cannot find module message unhelpful

simpljs

New Coder
Hi I have the following interaction, as you see the package ID is not found, immediately after being installed. This does not make any sense to me.
Why is there not more info in the error message?

Code:
PS C:\opnsrc\ndEnv\smartPower> npm install -g tplink-smarthome-api

changed 11 packages, and audited 12 packages in 1s

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities
PS C:\opnsrc\ndEnv\smartPower> node hello2.js
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'tplink-smarthome-api'
Require stack:
- C:\opnsrc\ndEnv\smartPower\hello2.js
^[90m    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)^[39m
^[90m    at Function.Module._load (node:internal/modules/cjs/loader:778:27)^[39m
^[90m    at Module.require (node:internal/modules/cjs/loader:1005:19)^[39m
^[90m    at require (node:internal/modules/cjs/helpers:102:18)^[39m
    at Object.<anonymous> (C:\opnsrc\ndEnv\smartPower\hello2.js:1:20)
^[90m    at Module._compile (node:internal/modules/cjs/loader:1103:14)^[39m
^[90m    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)^[39m

the hello2.js code is:


Code:
const { Client } = require('tplink-smarthome-api');


const client = new Client();


client.getDevice({ host: '10.0.0.60' }).then((device) => {

  device.getSysInfo().then(console.log);

});
 

Buy us a coffee!

Back
Top Bottom