Hello,
I’m fairly new to working with Typescript/NodeJS. I was able to follow tutorials to get a custom function built for a trigger. I have the handler.ts file and the rest of the file structure saved locally. Prior to today, the “8base deploy” command successfully deployed my trigger.
However, I am running into trouble importing this MQTT library. Following the instructions from the library’s author, I installed the library through npm with this command: npm install mqtt --save
. After, I ran npm install mqtt -g
. I noticed that the node_modules folder in my local 8base workspace now includes the mqtt library, so I assume this part was successful.
I added import * as mqtt from "mqtt";
alongside the other imports in my trigger’s handler.ts file. After this, I tried “8base deploy” and got this long error:
8base deploy
⠋ deploying…
Step: complete_error
{“response”:{“errors”:[{“message”:“Deployment error.”,“details”:{“compile”:"Compilation failed:\nError: "node_modules/mqtt-packet/types/index.d.ts" (1,23): Cannot find namespace ‘NodeJS’.\nError: "node_modules/mqtt-packet/types/index.d.ts" (2,25): Cannot find namespace ‘NodeJS’.\nError: "node_modules/mqtt-packet/types/index.d.ts" (35,26): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_modules/mqtt-packet/types/index.d.ts" (49,14): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_modules/mqtt-packet/types/index.d.ts" (52,14): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_modules/mqtt-packet/types/index.d.ts" (61,25): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_modules/mqtt-packet/types/index.d.ts" (74,26): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_modules/mqtt-packet/types/index.d.ts" (84,21): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_modules/mqtt-packet/types/index.d.ts" (90,23): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_modules/mqtt-packet/types/index.d.ts" (119,26): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_modules/mqtt-packet/types/index.d.ts" (244,17): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_modules/mqtt-packet/types/index.d.ts" (249,66): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_modules/mqtt/types/lib/client-options.d.ts" (4,35): Cannot find module ‘http’ or its corresponding type declarations.\nError: "node_modules/mqtt/types/lib/client-options.d.ts" (84,14): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_modules/mqtt/types/lib/client-options.d.ts" (102,25): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_modules/mqtt/types/lib/client-options.d.ts" (116,26): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_modules/mqtt/types/lib/client-options.d.ts" (124,29): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_modules/mqtt/types/lib/client-options.d.ts" (124,38): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_modules/mqtt/types/lib/client-options.d.ts" (128,30): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_modules/mqtt/types/lib/client-options.d.ts" (128,39): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_modules/mqtt/types/lib/client-options.d.ts" (132,28): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.\nError: "node_moderror: Compilation failed:
Error: “node_modules/mqtt-packet/types/index.d.ts” (1,23): Cannot find namespace ‘NodeJS’.
Error: “node_modules/mqtt-packet/types/index.d.ts” (2,25): Cannot find namespace ‘NodeJS’.
Error: “node_modules/mqtt-packet/types/index.d.ts” (35,26): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt-packet/types/index.d.ts” (49,14): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt-packet/types/index.d.ts” (52,14): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt-packet/types/index.d.ts” (61,25): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt-packet/types/index.d.ts” (74,26): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt-packet/types/index.d.ts” (84,21): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt-packet/types/index.d.ts” (90,23): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt-packet/types/index.d.ts” (119,26): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt-packet/types/index.d.ts” (244,17): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt-packet/types/index.d.ts” (249,66): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt/types/lib/client-options.d.ts” (4,35): Cannot find module ‘http’ or its corresponding type declarations.
Error: “node_modules/mqtt/types/lib/client-options.d.ts” (84,14): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt/types/lib/client-options.d.ts” (102,25): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt/types/lib/client-options.d.ts” (116,26): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt/types/lib/client-options.d.ts” (124,29): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt/types/lib/client-options.d.ts” (124,38): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt/types/lib/client-options.d.ts” (128,30): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt/types/lib/client-options.d.ts” (128,39): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt/types/lib/client-options.d.ts” (132,28): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt/types/lib/client-options.d.ts” (132,37): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt/types/lib/client-options.d.ts” (137,30): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt/types/lib/client-options.d.ts” (137,56): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt/types/lib/client-options.d.ts” (160,23): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt/types/lib/client.d.ts” (1,23): Cannot find type definition file for ‘node’.
Error: “node_modules/mqtt/types/lib/client.d.ts” (3,25): Cannot find module ‘events’ or its corresponding type declarations.
Error: “node_modules/mqtt/types/lib/client.d.ts” (72,66): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt/types/lib/client.d.ts” (144,52): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
Error: “node_modules/mqtt/types/lib/client.d.ts” (146,52): Cannot find name ‘Buffer’. Do you need to install type definitions for node? Trynpm i --save-dev @types/node
.
It suggests running npm i --save-dev @types/node
, so I tried that, but it didn’t help. If it makes any difference, my node version is v16.15.1. I’m running this from a Linux Mint machine.
Buried in that message, there’s a reference to Cannot find namespace 'NodeJS'
. This makes me think I’ve messed something up with my node configuration, but I am experienced enough with Node to know what that would be.