2

Reference article that I followed to upload files to SharePoint Library: Automate publishing of your SharePoint Framework scripts to Office 365 public CDN. I updated write-manifests.json with correct cdnBasePath value and below is the gulpfile code looks like

'use strict';

const gulp = require('gulp');
const build = require('@microsoft/sp-build-web');
const spSync = require('gulp-spsync');

build.task('upload-to-sharepoint', {
    execute: (config) => {
        return new Promise((resolve, reject) => {
            const deployFolder = require('./config/copy-assets.json');
            const folderLocation = `./${deployFolder.deployCdnPath}/**/*.js`;
            return gulp.src(folderLocation)
                .pipe(spSync({
                    "client_id": paramter.clientId,
                    "client_secret": paramter.clientSecret,
                    "site": `https://${paramter.tenant}.sharepoint.com/`,
                    "libraryPath": paramter.cdnLib,                                        
                    "publish": true
                }))
                .on('finish', resolve);
        });
    }
});
build.initialize(gulp);

When I run gulp task gulp upload-to-sharepoint --ship I am getting error:

Uploading sample_en-us_6148166309dc16f1da067900ef6b71b1.js Unhandled rejection Error in plugin 'gulp-spsync' Message: Request error

About to exit with code: 0 Process terminated before summary could be written, possible error in async code not continuing! Trying to exit with exit code 1

I can successfully run other gulp task like gulp bundle, gulp serve

1

When using this gulp task, is it actually uploading files? If yes, can you do a quick change in one of the source files to check if it can fix it?

In the node_modules folder, look for a folder named gulp-spsync and open the index.js file. In that file there should be three lines like this: cb(null,file). Change these to: cb(). Save the file, and run the gulp command again.

Be aware: this is not a solution to solve is as the gulp-spsync need to be fixed, but when it works, this can be changed in the code so that a new version of the plugin can be created.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.