node版本升级:与node-sass、sass-loader版本不兼容问题

npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! code 1
npm ERR! path D:\works\nuxt-yl\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: D:\Program Files\nodejs\node.exe D:\works\nuxt-yl\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   'D:\\Program Files\\nodejs\\node.exe',
npm ERR! gyp verb cli   'D:\\works\\nuxt-yl\\node_modules\\node-gyp\\bin\\node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@16.18.0 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb find Python Python is not set from command line or npm configuration
npm ERR! gyp verb find Python Python is not set from environment variable PYTHON
npm ERR! gyp verb find Python checking if "python3" can be used
npm ERR! gyp verb find Python - executing "python3" to get executable path
npm ERR! gyp verb find Python - "python3" is not in PATH or produced an error
npm ERR! gyp verb find Python checking if "python" can be used
npm ERR! gyp verb find Python - executing "python" to get executable path
npm ERR! gyp verb find Python - "python" is not in PATH or produced an error
npm ERR! gyp verb find Python checking if "python2" can be used
npm ERR! gyp verb find Python - executing "python2" to get executable path
npm ERR! gyp verb find Python - "python2" is not in PATH or produced an error
npm ERR! gyp verb find Python checking if Python is C:\Python37\python.exe
npm ERR! gyp verb find Python - executing "C:\Python37\python.exe" to get version
npm ERR! gyp verb find Python - "C:\Python37\python.exe" could not be run
npm ERR! gyp verb find Python checking if Python is C:\Python27\python.exe
npm ERR! gyp verb find Python - executing "C:\Python27\python.exe" to get version
npm ERR! gyp verb find Python - "C:\Python27\python.exe" could not be run
npm ERR! gyp verb find Python checking if the py launcher can be used to find Python
npm ERR! gyp verb find Python - executing "py.exe" to get Python executable path
npm ERR! gyp verb find Python - "py.exe" is not in PATH or produced an error
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
npm ERR! gyp ERR! find Python checking if "python3" can be used
npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
npm ERR! gyp ERR! find Python checking if "python" can be used
npm ERR! gyp ERR! find Python - "python" is not in PATH or produced an error
npm ERR! gyp ERR! find Python checking if "python2" can be used
npm ERR! gyp ERR! find Python - "python2" is not in PATH or produced an error
npm ERR! gyp ERR! find Python checking if Python is C:\Python37\python.exe
npm ERR! gyp ERR! find Python - "C:\Python37\python.exe" could not be run
npm ERR! gyp ERR! find Python checking if Python is C:\Python27\python.exe
npm ERR! gyp ERR! find Python - "C:\Python27\python.exe" could not be run
npm ERR! gyp ERR! find Python checking if the py launcher can be used to find Python
npm ERR! gyp ERR! find Python - "py.exe" is not in PATH or produced an error
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python You need to install the latest version of Python.
npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
npm ERR! gyp ERR! find Python you can try one of the following options:
npm ERR! gyp ERR! find Python - Use the switch --python="C:\Path\To\python.exe"
npm ERR! gyp ERR! find Python   (accepted by both node-gyp and npm)
npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
npm ERR! gyp ERR! find Python   npm config set python "C:\Path\To\python.exe"
npm ERR! gyp ERR! find Python For more information consult the documentation at:
npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
npm ERR! gyp ERR! stack     at PythonFinder.fail (D:\works\nuxt-yl\node_modules\node-gyp\lib\find-python.js:302:47)
npm ERR! gyp ERR! stack     at PythonFinder.runChecks (D:\works\nuxt-yl\node_modules\node-gyp\lib\find-python.js:136:21)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (D:\works\nuxt-yl\node_modules\node-gyp\lib\find-python.js:200:18)
npm ERR! gyp ERR! stack     at PythonFinder.execFileCallback (D:\works\nuxt-yl\node_modules\node-gyp\lib\find-python.js:266:16)
npm ERR! gyp ERR! stack     at exithandler (node:child_process:410:5)
npm ERR! gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:422:5)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! stack     at onErrorNT (node:internal/child_process:485:16)
npm ERR! gyp ERR! stack     at processTicksAndRejections (node:internal/process/task_queues:83:21)
npm ERR! gyp ERR! System Windows_NT 10.0.22621
npm ERR! gyp ERR! command "D:\\Program Files\\nodejs\\node.exe" "D:\\works\\nuxt-yl\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd D:\works\nuxt-yl\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.18.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

查看自己的node版本

 node -v

 如图所示我的版本是V16.18.0

去官方的github仓库去寻找合适的版本

node-sass: https://github.com/sass/node-sass/tags

sass-loader: https://github.com/webpack-contrib/sass-loader/tags

我版本对应的node-sass的版本安装

npm install node-sass@8.0.0 --save-dev

npm install sass-loader@10.4.1 --save-dev

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 对于Node.js版本16.16.0,建议使用以下版本node-sasssass-loader: - node-sass: ^5.0.0 - sass-loader: ^10.0.0 请注意,如果您使用的是Webpack 4或更早版本,则需要使用sass-loader v9.x。如果您使用的是Webpack 5,则应该升级到sass-loader v10.x。 当然,具体要使用哪个版本还要根据您的项目需求来确定,这只是一个建议版本。 ### 回答2: Node.js版本16.16.0 对应的 node-sasssass-loader 版本如下: 对于 node-sass,需要使用 npm 包管理工具进行安装,并且需要在 package.json 文件中声明依赖。在 Node.js v16.16.0 上,node-sass版本应该是 v4.14.1(可能会有一些微小变化,因此建议查看 npm 上最新的版本)。你可以使用以下命令来安装特定版本node-sass: ``` npm install node-sass@4.14.1 ``` 对于 sass-loader,也需要使用 npm 进行安装,并在 package.json 文件中添加依赖。sass-loader版本node-sass 版本有关联,因此版本号应该是相对应的。在 Node.js v16.16.0 上,sass-loader版本应该与 node-sass 版本相匹配,即 v10.1.1(也可以参考 npm 上的最新版本)。你可以使用以下命令安装特定版本sass-loader: ``` npm install sass-loader@10.1.1 ``` 请注意,以上版本号仅作为示例,如果需要其他特定版本,请查看官方文档或 npm 上的最新版本。另外,可以根据项目需求,在 package.json 文件中进行相应的版本声明和安装。 ### 回答3: node-sass是一个Node.js模块,提供了Sass的本地绑定。它允许将Sass文件编译为CSS文件。而sass-loader是一个webpack的loader,用于将Sass文件转换为CSS并导入到webpack构建中。 在查阅相关文档后,我了解到node16.16.0对应的node-sass版本应为6.0.1,而sass-loader版本则需根据具体使用的webpack版本来确定。一般来说,较新版本sass-loader会兼容较新版本的webpack。以下是常见的sass-loader版本对应的webpack版本: - sass-loader v10.x.x:兼容webpack v4.x.x和webpack v5.x.x - sass-loader v12.x.x:兼容webpack v5.x.x和webpack v6.x.x 所以,如果你的node版本为16.16.0,可以采用node-sass@6.0.1和sass-loader@10.x.x或sass-loader@12.x.x来搭配使用。当然,具体选择哪个版本还需结合你的构建环境和相关依赖的兼容性进行考量。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值