How do you resolve modules to use the smartsheet npm package on nodejs?
I am trying to use the Smartsheet API on nodejs (v8) on windows. When I add the smartsheet npm package, my solution no longer compiles. Easiest way to reproduce (though it reproduces without using create-react-app):
> npx create-react-appsolutionname
> cdsolutionname
> npm start
It works - your browser comes up with the default page showing.
> npm install --save smartsheet
You now need to reference smartsheet in the project. Opensolutionname/src/App.jsin your favorite text editor and at the top of the file, under the line that saysimport './App.css'add a new line, per the API docs:
var client = require('smartsheet');
Save and close the file.
> npm start
The solution no longer compiles. In the browser, you see the following error:
Failed to compile
./node_modules/smartsheet/lib/utils/httpRequestor.js
Module not found: Can't resolve 'request' in 'solutionname\node_modules\smartsheet\lib\utils'
You see the same 'Module not found' error in your console window.
I call it out on windows because when you install the smartsheet npm package, you get a missing optional dependency forfseventsthat is skipped because the platform is not OSX. FWIW I get this same exact error on Linux Mint.
Any idea of how this can be resolved to work?
thanks
Comments
-
J. Craig Williams ✭✭✭✭✭✭
I'd suggest asking this on StackOverflow with the smartsheet-api tag, if no one here answers.
https://stackoverflow.com/search?q=smartsheet-api
Craig
-
I ran into this issue too. The only way I could see how to get around it is to modify the util/httpRequestor.js file (in the Smartsheet SDK); however, since this is a public SDK, someone else probably came up with a way to do this without having to change it, right?
change:
var request = requestorConfig.request ||
Promise.promisifyAll(require("request"), {multiArgs: true});to:
var request = requestorConfig.request ||
Promise.promisifyAll(require("../request"), {multiArgs: true});