Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On Demand - cannot read properties of null / childprocess.spawnsync ENOENT Error #117

Open
yshwartzou opened this issue Sep 12, 2022 · 3 comments

Comments

@yshwartzou
Copy link

I have been getting an error when trying to use node-sp-auth in sp-rest-proxy in an On Demand configuration
I created a simple node.js package to isolate the the issue. Please see the pakcage.json below the error.

When I traced the error the issue appears to be that childproces.spawnsysnc is getting an EONENT error when tying to create the spawn of electron.

I was able to get a temporary workaround by referring to the absolute path to electron. But when referring to it as just 'electron' the ENOENT error is recieved.

Node Version: 16.15.1
Operating System: Windows 10
Error Recieved:

GET: https://www.sharepoint.com/sites/mysite/
Error TypeError: Cannot read properties of null (reading 'toString')
    at OnDemand.saveAuthData (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\node_modules\node-sp-auth\lib\src\auth\resolvers\OnDemand\OnDemand.js:83:44)
    at OnDemand.getAuth (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\node_modules\node-sp-auth\lib\src\auth\resolvers\OnDemand\OnDemand.js:38:28)
    at Object.getAuth (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\node_modules\node-sp-auth\lib\src\index.js:16:76)
    at SPClient.<anonymous> (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:69:51)
    at step (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:44:23)
    at Object.next (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:25:53)
    at c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:19:71
    at new Promise (<anonymous>)
    at __awaiter (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:15:12)
    at SPClient.fetch (C:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:65:20) {stack: 'TypeError: Cannot read properties of null (re…les\sp-rest-proxy\dist\utils\client.js:65:20)', message: 'Cannot read properties of null (reading 'toString')'}
arg1: TypeError: Cannot read properties of null (reading 'toString')\n    at OnDemand.saveAuthData (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\node_modules\\node-sp-auth\\lib\\src\\auth\\resolvers\\OnDemand\\OnDemand.js:83:44)\n    at OnDemand.getAuth (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\node_modules\\node-sp-auth\\lib\\src\\auth\\resolvers\\OnDemand\\OnDemand.js:38:28)\n    at Object.getAuth (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\node_modules\\node-sp-auth\\lib\\src\\index.js:16:76)\n    at SPClient.<anonymous> (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\dist\\utils\\client.js:69:51)\n    at step (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\dist\\utils\\client.js:44:23)\n    at Object.next (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\dist\\utils\\client.js:25:53)\n    at C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\dist\\utils\\client.js:19… …
Logger.error @ c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\logger.js:51:25
<anonymous> @ c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\core\BasicRouter.js:118:34
processTicksAndRejections @ internal/process/task_queues:96:5

Package.json

{
  "name": "spo-proxy",
  "version": "1.0.0",
  "description": "Proxy to SharePoint online",
  "main": "index.js",
  "scripts": {
    "proxy": "node ./index.js"
  },
  "author": "user",
  "license": "ISC",
  "dependencies": {
    "sp-rest-proxy": "^3.3.5"
  },
  "devDependencies": {
    "electron": "^20.1.3"
  }
}

Workaround configuration

{
  "siteUrl": "https://www.sharepoint.com/sites/mySite/",
  "strategy": "OnDemandCredentials",
  "ondemand": true,
  "force": true,
  "electron": "C:\\Users\\user\\NodeProjects\\my-project\\node_modules\\electron\\dist\\electron.exe"
}
@kadut001
Copy link

kadut001 commented Mar 3, 2023

Hi @yshwartzou I'm having the same issue when I get that TypeError: Cannot read properties of null (reading 'toString'). Were you able to fix your issue? I tried your work around and it still did not work for me

@pedromsfernandes
Copy link

It seems that this error does not happen in version 3.0.4. I rolled back and its working fine.

@fadinext
Copy link

After some research, I found that this error may be related with PR#108. On Windows, if I manually pass {shell:true} as it was on previous code, everything works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants