I’m trying to use the Airtable API for my website’s backend, but I’m running into an issue. When I try to include the Airtable module in my Node.js code with the following line:
var Airtable = require('airtable');
I get an error message when running the file using node [filepath]:
Error: Cannot find module 'airtable'
I made sure to install the module with the command:
npm install airtable
So, it should be installed. I expected my complete code to launch a server on localhost at port 3000, but I’m stuck at the require() line. How can I resolve this?
Been there - spent hours pulling my hair out over this one. Run the node command from the same directory as your package.json. I was running mine from a parent folder and node couldn’t find the modules in the nested project. Check if you’ve got a package-lock.json file too - if it’s missing, the install probably failed silently. Nuke your node_modules folder and run npm install again just to be safe.
try checking if you installed airtable in the same folder as your project. sometimes it gets installed globally instead of locally. also, run npm list airtable to double-check if it exists in your node_modules. hope this helps!