如何让Yarn与Node一起玩得很好?

时间:2018-04-02 04:09:54

标签: node.js yarnpkg node-sass vcbuild

我不熟悉Yarn,Node或Visual C ++。当我运行yarn install时,它会在yarn-error.log

中出错
Trace: 
  Error: C:\Users\Chloe\workspace\catalyst_research\node_modules\node-sass: Command failed.
  Exit code: 1
  Command: C:\windows\system32\cmd.exe
  Arguments: /d /s /c node scripts/build.js
  Directory: C:\Users\Chloe\workspace\catalyst_research\node_modules\node-sass
  Output:
  Building: C:\Program Files\nodejs\node.exe C:\Users\Chloe\workspace\catalyst_research\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
  gyp info it worked if it ends with ok
  gyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
  gyp verb cli   'C:\\Users\\Chloe\\workspace\\catalyst_research\\node_modules\\node-gyp\\bin\\node-gyp.js',
  gyp verb cli   'rebuild',
  gyp verb cli   '--verbose',
  gyp verb cli   '--libsass_ext=',
  gyp verb cli   '--libsass_cflags=',
  gyp verb cli   '--libsass_ldflags=',
  gyp verb cli   '--libsass_library=' ]
  gyp info using node-gyp@3.6.2
  gyp info using node@9.10.1 | win32 | x64
  gyp verb command rebuild []
  gyp verb command clean []
  gyp verb clean removing "build" directory
  gyp verb command configure []
  gyp verb check python checking for Python executable "python2" in the PATH
  gyp verb `which` failed Error: not found: python2
  gyp verb `which` failed     at getNotFoundError (C:\Users\Chloe\workspace\catalyst_research\node_modules\which\which.js:13:12)
  gyp verb `which` failed     at F (C:\Users\Chloe\workspace\catalyst_research\node_modules\which\which.js:68:19)
  gyp verb `which` failed     at E (C:\Users\Chloe\workspace\catalyst_research\node_modules\which\which.js:80:29)
  gyp verb `which` failed     at C:\Users\Chloe\workspace\catalyst_research\node_modules\which\which.js:89:16
  gyp verb `which` failed     at C:\Users\Chloe\workspace\catalyst_research\node_modules\isexe\index.js:42:5
  gyp verb `which` failed     at C:\Users\Chloe\workspace\catalyst_research\node_modules\isexe\windows.js:36:5
  gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:170:21)
  gyp verb `which` failed  python2 { Error: not found: python2
  gyp verb `which` failed     at getNotFoundError (C:\Users\Chloe\workspace\catalyst_research\node_modules\which\which.js:13:12)
  gyp verb `which` failed     at F (C:\Users\Chloe\workspace\catalyst_research\node_modules\which\which.js:68:19)
  gyp verb `which` failed     at E (C:\Users\Chloe\workspace\catalyst_research\node_modules\which\which.js:80:29)
  gyp verb `which` failed     at C:\Users\Chloe\workspace\catalyst_research\node_modules\which\which.js:89:16
  gyp verb `which` failed     at C:\Users\Chloe\workspace\catalyst_research\node_modules\isexe\index.js:42:5
  gyp verb `which` failed     at C:\Users\Chloe\workspace\catalyst_research\node_modules\isexe\windows.js:36:5
  gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:170:21)
  gyp verb `which` failed   stack: 'Error: not found: python2\n    at getNotFoundError (C:\\Users\\Chloe\\workspace\\catalyst_research\\node_modules\\which\\which.js:13:12)\n    at F (C:\\Users\\Chloe\\workspace\\catalyst_research\\node_modules\\which\\which.js:68:19)\n    at E (C:\\Users\\Chloe\\workspace\\catalyst_research\\node_modules\\which\\which.js:80:29)\n    at C:\\Users\\Chloe\\workspace\\catalyst_research\\node_modules\\which\\which.js:89:16\n    at C:\\Users\\Chloe\\workspace\\catalyst_research\\node_modules\\isexe\\index.js:42:5\n    at C:\\Users\\Chloe\\workspace\\catalyst_research\\node_modules\\isexe\\windows.js:36:5\n    at FSReqWrap.oncomplete (fs.js:170:21)',
  gyp verb `which` failed   code: 'ENOENT' }
  gyp verb check python checking for Python executable "python" in the PATH
  gyp verb `which` succeeded python C:\Python36\python.EXE
  gyp verb check python version `C:\Python36\python.EXE -c "import platform; print(platform.python_version());"` returned: "3.6.5\r\n"
  gyp verb could not find "C:\Python36\python.EXE". checking python launcher 
  gyp verb check python launcher python executable found: "C:\\Python27\\python.exe"
  gyp verb check python version `C:\Python27\python.exe -c "import platform; print(platform.python_version());"` returned: "2.7.14\r\n"
  gyp verb get node dir no --target version specified, falling back to host node version: 9.10.1
  gyp verb command install [ '9.10.1' ]
  gyp verb install input version string "9.10.1"
  gyp verb install installing version: 9.10.1
  gyp verb install --ensure was passed, so won't reinstall if already installed
  gyp verb install version is already installed, need to check "installVersion"
  gyp verb got "installVersion" 9
  gyp verb needs "installVersion" 9
  gyp verb install version is good
  gyp verb get node dir target node version installed: 9.10.1
  gyp verb build dir attempting to create "build" dir: C:\Users\Chloe\workspace\catalyst_research\node_modules\node-sass\build
  gyp verb build dir "build" dir needed to be created? C:\Users\Chloe\workspace\catalyst_research\node_modules\node-sass\build
  gyp verb Not using VS2017: Could not use PowerShell to find VS2017
  gyp verb build/config.gypi creating config file
  gyp verb build/config.gypi writing out config file: C:\Users\Chloe\workspace\catalyst_research\node_modules\node-sass\build\config.gypi
  gyp verb config.gypi checking for gypi file: C:\Users\Chloe\workspace\catalyst_research\node_modules\node-sass\config.gypi
  gyp verb common.gypi checking for gypi file: C:\Users\Chloe\workspace\catalyst_research\node_modules\node-sass\common.gypi
  gyp verb gyp gyp format was not specified; forcing "msvs"
  gyp info spawn C:\Python27\python.exe
  gyp info spawn args [ 'C:\\Users\\Chloe\\workspace\\catalyst_research\\node_modules\\node-gyp\\gyp\\gyp_main.py',
  gyp info spawn args   'binding.gyp',
  gyp info spawn args   '-f',
  gyp info spawn args   'msvs',
  gyp info spawn args   '-G',
  gyp info spawn args   'msvs_version=auto',
  gyp info spawn args   '-I',
  gyp info spawn args   'C:\\Users\\Chloe\\workspace\\catalyst_research\\node_modules\\node-sass\\build\\config.gypi',
  gyp info spawn args   '-I',
  gyp info spawn args   'C:\\Users\\Chloe\\workspace\\catalyst_research\\node_modules\\node-gyp\\addon.gypi',
  gyp info spawn args   '-I',
  gyp info spawn args   'C:\\Users\\Chloe\\.node-gyp\\9.10.1\\include\\node\\common.gypi',
  gyp info spawn args   '-Dlibrary=shared_library',
  gyp info spawn args   '-Dvisibility=default',
  gyp info spawn args   '-Dnode_root_dir=C:\\Users\\Chloe\\.node-gyp\\9.10.1',
  gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\Chloe\\workspace\\catalyst_research\\node_modules\\node-gyp',
  gyp info spawn args   '-Dnode_lib_file=C:\\Users\\Chloe\\.node-gyp\\9.10.1\\<(target_arch)\\node.lib',
  gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\Chloe\\workspace\\catalyst_research\\node_modules\\node-sass',
  gyp info spawn args   '-Dnode_engine=v8',
  gyp info spawn args   '--depth=.',
  gyp info spawn args   '--no-parallel',
  gyp info spawn args   '--generator-output',
  gyp info spawn args   'C:\\Users\\Chloe\\workspace\\catalyst_research\\node_modules\\node-sass\\build',
  gyp info spawn args   '-Goutput_dir=.' ]
  gyp verb command build []
  gyp verb build type Release
  gyp verb architecture x64
  gyp verb node dev dir C:\Users\Chloe\.node-gyp\9.10.1
  gyp verb found first Solution file build/binding.sln
  gyp verb could not find "msbuild.exe" in PATH - finding location in registry 
  gyp info spawn C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe
  gyp info spawn args [ 'build/binding.sln',
  gyp info spawn args   '/nologo',
  gyp info spawn args   '/p:Configuration=Release;Platform=x64' ]
  Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  Build started 4/2/2018 12:04:09 AM.
  Project "C:\Users\Chloe\workspace\catalyst_research\node_modules\node-sass\build\binding.sln" on node 1 (default targets).
  ValidateSolutionConfiguration:
    Building solution configuration "Release|x64".
  MSBUILD : error MSB3411: Could not load the Visual C++ component "VCBuild.exe". If the component is not installed, either 1) install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5, or 2) install Microsoft Visual Studio 2008.  [C:\Users\Chloe\workspace\catalyst_research\node_modules\node-sass\build\binding.sln]
  Done Building Project "C:\Users\Chloe\workspace\catalyst_research\node_modules\node-sass\build\binding.sln" (default targets) -- FAILED.

  Build FAILED.

  "C:\Users\Chloe\workspace\catalyst_research\node_modules\node-sass\build\binding.sln" (default target) (1) ->
  (libsass target) -> 
    MSBUILD : error MSB3411: Could not load the Visual C++ component "VCBuild.exe". If the component is not installed, either 1) install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5, or 2) install Microsoft Visual Studio 2008.  [C:\Users\Chloe\workspace\catalyst_research\node_modules\node-sass\build\binding.sln]

      0 Warning(s)
      1 Error(s)

  Time Elapsed 00:00:01.21
  gyp ERR! build error 
  gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
  gyp ERR! stack     at ChildProcess.onExit (C:\Users\Chloe\workspace\catalyst_research\node_modules\node-gyp\lib\build.js:258:23)
  gyp ERR! stack     at ChildProcess.emit (events.js:180:13)
  gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
  gyp ERR! System Windows_NT 6.3.9600
  gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Chloe\\workspace\\catalyst_research\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
  gyp ERR! cwd C:\Users\Chloe\workspace\catalyst_research\node_modules\node-sass
  gyp ERR! node -v v9.10.1
  gyp ERR! node-gyp -v v3.6.2
  gyp ERR! not ok 
  Build failed with error code: 1
      at ProcessTermError.MessageError (C:\Program Files (x86)\Yarn\lib\cli.js:186:110)
      at new ProcessTermError (C:\Program Files (x86)\Yarn\lib\cli.js:226:113)
      at ChildProcess.<anonymous> (C:\Program Files (x86)\Yarn\lib\cli.js:30281:17)
      at ChildProcess.emit (events.js:180:13)
      at maybeClose (internal/child_process.js:936:16)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)

我安装了chocolatey install vcbuildtools。我改为node_modules\node-sass并运行以下似乎有效(第二次运行):

C:\Users\Chloe\workspace\catalyst_research\node_modules\node-sass>node scripts/build.js --msvs_version=2015
Binary found at C:\Users\Chloe\workspace\catalyst_research\node_modules\node-sass\vendor\win32-x64-59\binding.node
Testing binary
Binary is fine

但是当我回到项目根目录并运行yarn install时,它会出现同样的错误!

我尝试了npm config --global set msvs_version 2015,但没有帮助。

Windows 8.1,节点9.10.1

0 个答案:

没有答案