Closed tsauvajon closed 5 years ago
It compiles just fine for me. No global dependencies are required at all.
When running tsc -p .
from an npm task a locally installed TypeScript and compiler are used (/node_modules/.bin/tsc
). Seems like you run tsc
in the console and an old TypeScript version is installed which "doesn't know" what these options are.
Electron is also not required optional dependency which is used by another dependency for On-Demand auth only.
You are completely right about tsc. The problem was with my build script (I incorrectly adapted it to run on Windows).
I am still getting the following error message when running the project and using the OnDemandCredentials
strategy:
'electron' is not recognized as an internal or external command
Using the UserCredentials
strategy yields a different error:
> ts-node ./test/upload.test.ts
SyntaxError: Unexpected token < in JSON at position 2
at JSON.parse (<anonymous>)
at [...]\pnp-upload\node_modules\@pnp\odata\dist\odata.es5.umd.js:74:93
at processTicksAndRejections (internal/process/task_queues.js:89:5)
EDIT: after investigating, the dependency is getting a full HTML error page (with status code 200??), that's why it cannot parse it as JSON
What version of SharePoint are you targeting to?
I'm using SharePoint Online (Office 365)
Just to make sure I'm doing it correctly - I'm trying to upload a file in a document library. The URL I'm using looks like: https://[company].sharepoint.com/sites/[team-site]/[Library name]/Forms/AllItems.aspx
This is obviously an incorrect URL and the cause of the issue. This is a URL to a view page but not a folder. Should be just /sites/[team-site]/[Library name]
for root folder in a lib and /sites/[team-site]/[Library name]/[Folder]/[Sub Folder]
.
Thanks again for your help; how are you supposed to get the correct URL in the first place?
I just tried to use /sites/[team-site]/[Library name]
, which returns a 404.
I tried creating a folder in the lib, used /sites/[team-site]/[Library name]/[Folder]
: same issue, 404.
I realise this is not a helpdesk nor a problem with your repo so thanks again for the time you've spent answering my newbie questions.
In SharePoint API terms it is ServerRelativeUrl
property.
In practice, you just taking parts from the URL of the view (lib root folder) and folder's relative path.
I was able to upload a document!
I went into the code and edited the folderUrl
, in upload.test.ts:8
. The Shared Documents
was hard coded, I changed it to my Library name and it now works as expected.
I am trying to use your repo but I was not able to compile it. I've globally installed two missing dependencies (tsc and electron), but it still won't compile:
What version of
tsc
are you using for this project?