当前位置: 首页 > 工具软件 > node-launcher > 使用案例 >

安装node-sass遇到的各种各样的问题及解决

郗欣嘉
2023-12-01

node-sass


提示没有安装python

gyp verb `which` failed     at D:\web\node_modules\which\which.js:90:16
gyp verb `which` failed     at D:\web\node_modules\isexe\index.js:44:5
gyp verb `which` failed     at D:\web\node_modules\isexe\windows.js:29:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:123:15) code: 'ENOENT' }
gyp verb could not find "python". checking python launcher
gyp verb could not find "python". guessing location
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (D:\web\node_modules\node-gyp\lib\configure.js:449:14)
gyp ERR! stack     at D:\web\node_modules\node-gyp\lib\configure.js:404:11
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:123:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\web\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd D:\web\node_modules\node-sass
gyp ERR! node -v v6.3.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
Build failed
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.13
npm WARN optional Skipping failed optional dependency /gulp-watch/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.13
npm WARN web@1.0.0 No repository field.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "node-sass"
npm ERR! node v6.3.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE

npm ERR! node-sass@3.8.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@3.8.0 postinstall script 'node scripts/build.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node scripts/build.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-sass
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-sass
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\web\npm-debug.log

提示Framework build失败

根据http://stackoverflow.com/questions/21562038/node-gyp-build-error-windows-x64

npm config set msvs_version 2013 --global
gyp info spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\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 2016/7/14 13:53:37.
Project "C:\Users\tj\AppData\Roaming\npm\node_modules\node-sass\build\binding.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Release|x64".
Project "C:\Users\tj\AppData\Roaming\npm\node_modules\node-sass\build\binding.sln" (1) is building "C:\Users\tj\AppData\Roaming\npm\node_modules\node-sass\build\binding.vcxproj.metaproj" (2) on node 1 (default targets).
Project "C:\Users\tj\AppData\Roaming\npm\node_modules\node-sass\build\binding.vcxproj.metaproj" (2) is building "C:\Users\tj\AppData\Roaming\npm\node_modules\node-sass\build\src\libsass.vcxproj" (3) on node 1 (default targets).
C:\Users\tj\AppData\Roaming\npm\node_modules\node-sass\build\src\libsass.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Done Building Project "C:\Users\tj\AppData\Roaming\npm\node_modules\node-sass\build\src\libsass.vcxproj" (default targets) -- FAILED.
Done Building Project "C:\Users\tj\AppData\Roaming\npm\node_modules\node-sass\build\binding.vcxproj.metaproj" (default targets) -- FAILED.
Done Building Project "C:\Users\tj\AppData\Roaming\npm\node_modules\node-sass\build\binding.sln" (default targets) -- FAILED.

Build FAILED.

"C:\Users\tj\AppData\Roaming\npm\node_modules\node-sass\build\binding.sln" (default target) (1) ->
"C:\Users\tj\AppData\Roaming\npm\node_modules\node-sass\build\binding.vcxproj.metaproj" (default target) (2) ->
"C:\Users\tj\AppData\Roaming\npm\node_modules\node-sass\build\src\libsass.vcxproj" (default target) (3) ->
  C:\Users\tj\AppData\Roaming\npm\node_modules\node-sass\build\src\libsass.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.04
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\tj\AppData\Roaming\npm\node_modules\node-sass\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\tj\\AppData\\Roaming\\npm\\node_modules\\node-sass\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\tj\AppData\Roaming\npm\node_modules\node-sass
gyp ERR! node -v v6.3.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
Build failed
C:\Users\tj\AppData\Roaming\npm
`-- (empty)

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--msvs_version=2012" "node-sass" "-g"
npm ERR! node v6.3.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE

npm ERR! node-sass@3.8.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@3.8.0 postinstall script 'node scripts/build.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node scripts/build.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-sass
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-sass
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\web\npm-debug.log
npm ERR! code 1

提示ERROR in %1 is not a valid Win32 application.

ERROR in %1 is not a valid Win32 application.
\\?\D:\web\node_modules\node-sass\vendor\win32-x64-48\binding.node
 @ ./src/scss/page/login.scss 4:14-138 13:2-17:4 14:20-144

ERROR in %1 is not a valid Win32 application.
\\?\D:\web\node_modules\node-sass\vendor\win32-x64-48\binding.node
 @ ./src/scss/page/finance.scss 4:14-140 13:2-17:4 14:20-146

ERROR in %1 is not a valid Win32 application.
\\?\D:\web\node_modules\node-sass\vendor\win32-x64-48\binding.node
 @ ./src/scss/util/style.scss 4:14-138 13:2-17:4 14:20-144

ERROR in %1 is not a valid Win32 application.
\\?\D:\web\node_modules\node-sass\vendor\win32-x64-48\binding.node
 @ ./src/scss/style.scss 4:14-132 13:2-17:4 14:20-138

也有说node版本太高导致的

(https://github.com/vigetlabs/gulp-starter/issues/237)

去官网下载https://nodejs.org/en/ 下载4.4.7还是不行


最后解决方法是直接用淘宝的镜像安装成功

https://npm.taobao.org/

npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install node-sass

结束语

前前后后折腾了大半天,也没有提示被墙的软硬,最后是用淘宝镜像解决的,看来学习前端之路注定是一条不平凡之路。

 类似资料: