Unable to build my SPfx, error @microsoft/sharepoint Command failed with exit code 1: npm install

john john Pter 1,040 Reputation points
2024-08-28T01:35:18.3166667+00:00

I want to build an SPFX, i did the following steps:-

1)Inside c: i created a folder name SPFx

2)inside node.js i have this :-

User's image3)I run this command:-

yo @microsoft/sharepoint

User's image

User's image

but i got this error:-

User's image

Here is the logs

2001 http fetch GET 200 https://registry.npmjs.org/normalize-package-data 145ms (cache revalidated) 2002 http fetch GET 200 https://registry.npmjs.org/any-promise 150ms (cache revalidated) 2003 http fetch GET 200 https://registry.npmjs.org/detect-indent 153ms (cache revalidated) 2004 http fetch GET 200 https://registry.npmjs.org/sort-keys 155ms (cache revalidated) 2005 http fetch GET 200 https://registry.npmjs.org/p-reflect 154ms (cache revalidated) 2006 http fetch GET 200 https://registry.npmjs.org/@pnpm%2fwrite-project-manifest 536ms (cache revalidated) 2007 http fetch GET 200 https://registry.npmjs.org/read-yaml-file 614ms (cache revalidated) 2008 timing idealTree:node_modules/@pnpm/link-bins Completed in 627ms 2009 timing idealTree:node_modules/@pnpm/error Completed in 0ms 2010 silly placeDep ROOT fast-glob@3.3.2 OK for: @pnpm/package-bins@4.1.0 want: ^3.2.4 2011 silly fetch manifest @nodelib/fs.stat@^2.0.2 2012 silly fetch manifest @nodelib/fs.walk@^1.2.3 2013 silly fetch manifest glob-parent@^5.1.2 2014 silly fetch manifest merge2@^1.3.0 2015 http fetch GET 200 https://registry.npmjs.org/@nodelib%2ffs.stat 268ms (cache revalidated) 2016 http fetch GET 200 https://registry.npmjs.org/@nodelib%2ffs.walk 278ms (cache revalidated) 2017 timing idealTree:node_modules/@pnpm/package-bins Completed in 281ms 2018 timing idealTree:node_modules/@pnpm/read-modules-dir Completed in 0ms 212225 info run es5-ext@0.10.64 postinstall node_modules/es5-ext node -e "try{require('./_postinstall')}catch(e){}" || exit 0 12226 info run node-sass@4.14.1 postinstall node_modules/node-sass node scripts/build.js 12227 info run es5-ext@0.10.64 postinstall { code: 0, signal: null } 12228 timing build:run:postinstall:node_modules/es5-ext Completed in 215ms 12229 info run node-sass@4.14.1 postinstall { code: 1, signal: null } 12230 timing reify:rollback:createSparse Completed in 23161ms 12231 timing reify:rollback:retireShallow Completed in 0ms 12232 timing command:install Completed in 160278ms 12233 verbose stack Error: command failed 12233 verbose stack at ChildProcess.<anonymous> (C:\Users\mohan\AppData\Roaming\nvm\v16.13.1\node_modules\npm\node_modules\@npmcli\promise-spawn\index.js:64:27) 12233 verbose stack at ChildProcess.emit (node:events:390:28) 12233 verbose stack at maybeClose (node:internal/child_process:1064:16) 12233 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5) 12234 verbose pkgid node-sass@4.14.1 12235 verbose cwd c:\SPFX 12236 verbose Windows_NT 10.0.22631 12237 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" 12238 verbose node v16.13.1 12239 verbose npm v8.1.2 12240 error code 1 12241 error path c:\SPFX\node_modules\node-sass 12242 error command failed 12243 error command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/build.js 12244 error Building: C:\Program Files\nodejs\node.exe c:\SPFX\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library= 12245 error gyp info it worked if it ends with ok 12245 error gyp verb cli [ 12245 error gyp verb cli 'C:\\Program Files\\nodejs\\node.exe', 12245 error gyp verb cli 'c:\\SPFX\\node_modules\\node-gyp\\bin\\node-gyp.js', 12245 error gyp verb cli 'rebuild', 12245 error gyp verb cli '--verbose', 12245 error gyp verb cli '--libsass_ext=', 12245 error gyp verb cli '--libsass_cflags=', 12245 error gyp verb cli '--libsass_ldflags=', 12245 error gyp verb cli '--libsass_library=' 12245 error gyp verb cli ] 12245 error gyp info using node-gyp@3.8.0 12245 error gyp info using node@16.13.1 | win32 | x64 12245 error gyp verb command rebuild [] 12245 error gyp verb command clean [] 12245 error gyp verb clean removing "build" directory 12245 error gyp verb command configure [] 12245 error gyp verb check python checking for Python executable "python2" in the PATH 12245 error gyp verb whichfailed Error: not found: python2 12245 error gyp verbwhichfailed at getNotFoundError (c:\SPFX\node_modules\node-gyp\node_modules\which\which.js:13:12) 12245 error gyp verbwhichfailed at F (c:\SPFX\node_modules\node-gyp\node_modules\which\which.js:68:19) 12245 error gyp verbwhichfailed at E (c:\SPFX\node_modules\node-gyp\node_modules\which\which.js:80:29) 12245 error gyp verbwhichfailed at c:\SPFX\node_modules\node-gyp\node_modules\which\which.js:89:16 12245 error gyp verbwhichfailed at c:\SPFX\node_modules\isexe\index.js:42:5 12245 error gyp verbwhichfailed at c:\SPFX\node_modules\isexe\windows.js:36:5 12245 error gyp verbwhichfailed at FSReqCallback.oncomplete (node:fs:198:21) 12245 error gyp verbwhichfailed python2 Error: not found: python2 12245 error gyp verbwhichfailed at getNotFoundError (c:\SPFX\node_modules\node-gyp\node_modules\which\which.js:13:12) 12245 error gyp verbwhichfailed at F (c:\SPFX\node_modules\node-gyp\node_modules\which\which.js:68:19) 12245 error gyp verbwhichfailed at E (c:\SPFX\node_modules\node-gyp\node_modules\which\which.js:80:29) 12245 error gyp verbwhichfailed at c:\SPFX\node_modules\node-gyp\node_modules\which\which.js:89:16 12245 error gyp verbwhichfailed at c:\SPFX\node_modules\isexe\index.js:42:5 12245 error gyp verbwhichfailed at c:\SPFX\node_modules\isexe\windows.js:36:5 12245 error gyp verbwhichfailed at FSReqCallback.oncomplete (node:fs:198:21) { 12245 error gyp verbwhichfailed code: 'ENOENT' 12245 error gyp verbwhichfailed } 12245 error gyp verb check python checking for Python executable "python" in the PATH 12245 error gyp verbwhichfailed Error: not found: python 12245 error gyp verbwhichfailed at getNotFoundError (c:\SPFX\node_modules\node-gyp\node_modules\which\which.js:13:12) 12245 error gyp verbwhichfailed at F (c:\SPFX\node_modules\node-gyp\node_modules\which\which.js:68:19) 12245 error gyp verbwhichfailed at E (c:\SPFX\node_modules\node-gyp\node_modules\which\which.js:80:29) 12245 error gyp verbwhichfailed at c:\SPFX\node_modules\node-gyp\node_modules\which\which.js:89:16 12245 error gyp verbwhichfailed at c:\SPFX\node_modules\isexe\index.js:42:5 12245 error gyp verbwhichfailed at c:\SPFX\node_modules\isexe\windows.js:36:5 12245 error gyp verbwhichfailed at FSReqCallback.oncomplete (node:fs:198:21) 12245 error gyp verbwhichfailed python Error: not found: python 12245 error gyp verbwhichfailed at getNotFoundError (c:\SPFX\node_modules\node-gyp\node_modules\which\which.js:13:12) 12245 error gyp verbwhichfailed at F (c:\SPFX\node_modules\node-gyp\node_modules\which\which.js:68:19) 12245 error gyp verbwhichfailed at E (c:\SPFX\node_modules\node-gyp\node_modules\which\which.js:80:29) 12245 error gyp verbwhichfailed at c:\SPFX\node_modules\node-gyp\node_modules\which\which.js:89:16 12245 error gyp verbwhichfailed at c:\SPFX\node_modules\isexe\index.js:42:5 12245 error gyp verbwhichfailed at c:\SPFX\node_modules\isexe\windows.js:36:5 12245 error gyp verbwhichfailed at FSReqCallback.oncomplete (node:fs:198:21) { 12245 error gyp verbwhichfailed code: 'ENOENT' 12245 error gyp verb``` which failed } `` 12245 error gyp verb could not find "python". checking python launcher 12245 error gyp verb could not find "python". guessing location 12245 error gyp verb ensuring that file exists: C:\Python27\python.exe 12245 error gyp ERR! configure error 12245 error gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable. 12245 error gyp ERR! stack at PythonFinder.failNoPython (c:\SPFX\node_modules\node-gyp\lib\configure.js:484:19) 12245 error gyp ERR! stack at PythonFinder.<anonymous> (c:\SPFX\node_modules\node-gyp\lib\configure.js:509:16) 12245 error gyp ERR! stack at callback (c:\SPFX\node_modules\graceful-fs\polyfills.js:306:20) 12245 error gyp ERR! stack at FSReqCallback.oncomplete (node:fs:198:21) 12245 error gyp ERR! System Windows_NT 10.0.22631 12245 error gyp ERR! command "C:\Program Files\nodejs\node.exe" "c:\SPFX\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" 12245 error gyp ERR! cwd c:\SPFX\node_modules\node-sass 12245 error gyp ERR! node -v v16.13.1 12245 error gyp ERR! node-gyp -v v3.8.0 12245 error gyp ERR! not ok 12245 error Build failed with error code: 1 12246 verbose exit 1then i run npm install, but i got this error:-

`User's image

`

any advice?

Microsoft 365 and Office SharePoint Development
0 comments No comments
{count} votes

Accepted answer
  1. Maycon Batista 336 Reputation points
    2024-08-28T03:10:13.2266667+00:00

    1000148802

    I had a similar problem, and it was due to the npm version. To resolve it, I had to uninstall all versions of Node and reinstall them. Sure! Here are the steps to uninstall Node.js and npm, including clearing the cache, on Windows:

    1. Clear the npm cache:
      
         npm cache clean --force
      
      
    2. Uninstall Node.js and npm:
      • Open the Control Panel by searching for it in the Start menu.
      • Go to "Programs and Features" and find Node.js in the list.
      • Select Node.js and click "Uninstall".
    3. Remove residual folders:
      • Check and remove the following folders if they exist:
        
             C:\Program Files\nodejs
        
             C:\Program Files (x86)\nodejs
        
             C:\Users\{YourUsername}\AppData\Roaming\npm
        
             C:\Users\{YourUsername}\AppData\Roaming\npm-cache
        
             C:\Users\{YourUsername}\.npmrc
        
             C:\Users\{YourUsername}\AppData\Local\Temp\npm-*
        
        
    4. Check environment variables:
      • Ensure there are no references to Node.js or npm in the PATH environment variable.
    5. Restart your computer to apply the changes.

    These steps should help you completely remove Node.js and npm from your Windows system.

    If there are any misunderstandings, please let me know

    Best regards,

    Maycon Novaes

    If the Answer is helpful, please click "Accept Answer" and upvote it.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.