sp-dev-fx-webparts: Running gulp package-solution gives errors unless gulp serve has been run previously

Category

  • Question
  • Bug
  • Enhancement

Expected or Desired Behavior

A solution package should be created using gulp package-solution from a newly scaffolded SPFx solution without errors.

Observed Behavior

If you scaffold a solution and immediately attempt to use gulp package-solution you get errors. If you first do gulp serve, a subsequent attempt at gulp package-solution succeeds. This suggests that there is an error in the gulp dependencies, and that the package-solution task should have a dependency on webpack, write-manifests, copy-assets etc. Note that running gulp build does not solve the problem, you have to go through the gulp serve path.

Steps to Reproduce

Run SharePoint Yeoman generator to create a new SPFx solution using basic JavaScript HelloWorld web part: yo @microsoft/sharepoint. Immediately try to create the deployment package using gulp package-solution.

Example Output

PS C:\Users\BillA\Documents\Projects\OfficeDev\DeployTest1> gulp package-solution
Build target: DEBUG
[17:33:19] Using gulpfile ~\Documents\Projects\OfficeDev\DeployTest1\gulpfile.js
[17:33:19] Starting gulp
[17:33:19] Starting 'package-solution'...
[17:33:19] Starting subtask 'package-solution'...
[17:33:19] Verifying configuration...
TypeError: error is not a function
    at Object.createPackage [as default] (C:\Users\BillA\Documents\Projects\OfficeDev\DeployTest1\node_modules\@microsoft\sp-build-core-tasks\lib\packageSolution\packageSolution
reatePackage.js:58:9)
    at DestroyableTransform._flush (C:\Users\BillA\Documents\Projects\OfficeDev\DeployTest1\node_modules\@microsoft\sp-build-core-tasks\lib\packageSolution\PackageSolutionTask.j
70:36)
    at DestroyableTransform.<anonymous> (C:\Users\BillA\Documents\Projects\OfficeDev\DeployTest1\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:115:
)
    at DestroyableTransform.g (events.js:291:16)
    at emitNone (events.js:86:13)
    at DestroyableTransform.emit (events.js:185:7)
    at prefinish (C:\Users\BillA\Documents\Projects\OfficeDev\DeployTest1\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:494:12)
    at finishMaybe (C:\Users\BillA\Documents\Projects\OfficeDev\DeployTest1\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:502:7)
    at endWritable (C:\Users\BillA\Documents\Projects\OfficeDev\DeployTest1\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:514:3)
    at DestroyableTransform.Writable.end (C:\Users\BillA\Documents\Projects\OfficeDev\DeployTest1\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:484:
)
    at DestroyableTransform.onend (C:\Users\BillA\Documents\Projects\OfficeDev\DeployTest1\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:523:10)
    at DestroyableTransform.g (events.js:291:16)
    at emitNone (events.js:91:20)
    at DestroyableTransform.emit (events.js:185:7)
    at C:\Users\BillA\Documents\Projects\OfficeDev\DeployTest1\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:965:16
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
[17:33:19] Error - Unknown
 error is not a function
[17:33:19] Error - 'package-solution' sub task errored after 128 ms
 No manifests were found in 'dist\*.json'. Ensure a build has completed successfully and that paths.manifestsMatch is correct
[17:33:19] 'package-solution' errored after 148 ms
[17:33:19]
[17:33:20] ==================[ Finished ]==================
Error - Unknown
 error is not a function
Error - 'package-solution' sub task errored after 128 ms
 No manifests were found in 'dist\*.json'. Ensure a build has completed successfully and that paths.manifestsMatch is correct
[17:33:20] Project deploy-test-1 version: 0.0.1
[17:33:20] Build tools version: 2.5.1
[17:33:20] Node version: v6.10.1
[17:33:20] Total duration: 9.26 s
[17:33:20] Task errors: 3
[17:33:20] Error - 'undefined' errored after
 "orchestration aborted"

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 20 (8 by maintainers)

Most upvoted comments

You can still use the latest Yeoman generator and select “SharePoint 2016 onwards, including 2019 and SharePoint Online” when it asks for baseline packages. This will load SPFx v1.1.0. See https://docs.microsoft.com/en-us/sharepoint/dev/spfx/sharepoint-2016-support.

I think it’s unreasonable to expect Microsoft to support the latest SPFx with older versions of SharePoint.

I said Microsoft is terrible because there is no single document talk about which version SP2016 is supporting. It force everyone try and error. Before I raise my question about gulp, I have already troubleshooting for half month just to get to the this step. =(

@devoooo4u it seems like you have something else running on port 4321. Could it be that you’re trying to serve multiple SPFx projects at the same time?

@hugoabernier it now gives a message saying please build first and then throws a load more errors. That’s near enough a resolution for me 😃

Actually it would be sufficient to run gulp bundle, nevertheless the dependency is there and should be made explicitly in the package-solution task.