Search code examples
gitsharepointnpm-installspfx

Yeoman will not install modules when choosing @pnp/generator-spfx


Starting my first sharepoint dev project, and I have all the data and most of the flows in place. Now I need to get the V1 of the interface working. From what I have seen I should be using @pnp/spfx over @microsoft/sharepoint, but when I do the npm modules never get installed.

The error in the terminal is:

npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno -4058
npm ERR! enoent An unknown git error occurred
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

Looking at the logs when things are fetched everything come back with a 200. I can navigate to the locations and get the data to appear.

Below is the error from the log

9750 verbose stack Error: An unknown git error occurred
9750 verbose stack     at makeError (C:\Users\a00536820\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\git\lib\make-error.js:28:13)
9750 verbose stack     at C:\Users\a00536820\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\git\lib\spawn.js:37:26
9750 verbose stack     at processTicksAndRejections (node:internal/process/task_queues:96:5)
9751 verbose cwd C:\code\createNewProject
9752 verbose Windows_NT 10.0.22000
9753 verbose node v16.13.0
9754 verbose npm  v8.19.4
9755 error code ENOENT
9756 error syscall spawn git
9757 error path git
9758 error errno -4058
9759 error enoent An unknown git error occurred
9760 error enoent This is related to npm not being able to find a file.
9760 error enoent
9761 verbose exit -4058
9762 timing npm Completed in 20022ms
9763 verbose unfinished npm timer reify 1693164477702
9764 verbose unfinished npm timer reify:loadTrees 1693164477711
9765 verbose code -4058

I have checked the version compatibility requirements between SPFX, Node and NPM based on what is posted here and they seem to be fine.

I have tried to run npm install. No joy. Tried to get them installed one at a time. No joy Thought that lock files were an issue. No joy Thought maybe VS Code had things locked. No joy. Rebooted. No joy Thought maybe OneDrive sync was an issue so I moved to an unsynched folder. No joy.


Solution

  • Took a while, but I was able to figure out the multiple issues that I was facing. Some are embarrassing while others are not, but hey... This is my first time taking a stab at this platform and development toolset.

    First issue was that I thought that I had the versions correct, but I did in fact not have compatible versions installed. And to top it off when I was trying to fix the versioning issue instead of installing a different version of node or using nvm I just overwrote the node executable in the install directory.

    Once I realized how bad it was I wiped my whole node setup and installed and verified that I actually had the correct versions, but was still getting the same error.

    What it all came down to was the fact that I did not know that I did not have git installed, as the video that I was watching on getting the environment set up did not mention it and stated emphatically that all I needed to do was follow their steps and I would be fine. They did not say anything about git at all.

    Well I am up and running. I hope this helps someone in the future not waste 4 days.