You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为什么我的Nuxt.js项目出现与eslint-module相关的致命报错?

Nuxt项目eslint-module相关报错问题

我目前接手了一个他人开发的Nuxt.js项目,最初遇到了empty_nuxt报错,通过几个步骤解决该问题后,现在又出现了与eslint-module相关的Nuxt致命报错。

已尝试的解决方案

以下操作均未生效:

  • npm install eslint --save-dev
  • npm i node-sass-import
  • ./node_modules/.bin/eslint --init
  • npm install --save-dev @nuxtjs/eslint-module

npm运行完整报错日志

npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated debug@4.2.0: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity issue, recommended you upgrade to 3.2.7 or 4.3.1.
npm WARN deprecated debug@4.2.0: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity issue, recommended you upgrade to 3.2.7 or 4.3.1.
npm WARN deprecated debug@4.2.0: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity issue, recommended you upgrade to 3.2.7 or 4.3.1.
npm WARN deprecated debug@4.2.0: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity issue, recommended you upgrade to 3.2.7 or 4.3.1.
npm WARN deprecated debug@4.2.0: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity issue, recommended you upgrade to 3.2.7 or 4.3.1.
npm WARN deprecated debug@4.2.0: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity issue, recommended you upgrade to 3.2.7 or 4.3.1.
npm WARN deprecated debug@4.2.0: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity issue, recommended you upgrade to 3.2.7 or 4.3.1.
npm WARN deprecated debug@4.2.0: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity issue, recommended you upgrade to 3.2.7 or 4.3.1.
npm WARN deprecated debug@4.2.0: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity issue, recommended you upgrade to 3.2.7 or 4.3.1.
npm WARN deprecated debug@4.2.0: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity issue, recommended you upgrade to 3.2.7 or 4.3.1.
npm WARN deprecated debug@4.2.0: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity issue, recommended you upgrade to 3.2.7 or 4.3.1.
npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity issue, recommended you upgrade to 3.2.7 or 4.3.1.
npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity issue, recommended you upgrade to 3.2.7 or 4.3.1.
npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity issue, recommended you upgrade to 3.2.7 or 4.3.1.
npm WARN deprecated html-webpack-plugin@3.2.0: 3.x is no longer supported
npm WARN deprecated eslint-loader@3.0.3: This loader has been deprecated. Please use eslint-webpack-plugin
npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package 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 problematic.
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 problematic.
npm WARN deprecated request@2.88.2: request has been deprecated
npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please upgrade to mkdirp 1.x, which uses native Promise API.
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates.
npm WARN deprecated core-js@2.6.11: core-js@<3.3 is no longer maintained and not recommended for usage. Due to the number of issues, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your version of core-js.
npm ERR! code 1
npm ERR! path C:\Users\Seda\Desktop\huseyinsavran\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: F:\Programlar\node.exe C:\Users\Seda\Desktop\huseyinsavran\node_modules\node-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   'F:\\Programlar\\node.exe',
npm ERR! gyp verb cli   'C:\\Users\\Seda\\Desktop\\huseyinsavran\\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@3.8.0
npm ERR! gyp info using node@16.10.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 check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (C:\Users\Seda\Desktop\huseyinsavran\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (C:\Users\Seda\Desktop\huseyinsavran\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (C:\Users\Seda\Desktop\huseyinsavran\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at C:\Users\Seda\Desktop\huseyinsavran\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at C:\Users\Seda\Desktop\huseyinsavran\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at C:\Users\Seda\Desktop\huseyinsavran\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (C:\Users\Seda\Desktop\huseyinsavran\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (C:\Users\Seda\Desktop\huseyinsavran\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (C:\Users\Seda\Desktop\huseyinsavran\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at C:\Users\Seda\Desktop\huseyinsavran\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` succeeded python F:\Anaconda3\python.EXE
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: F:\Anaconda3\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack   File "<string>", line 1
npm ERR! gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack                                ^
npm ERR! gyp ERR! stack SyntaxError: invalid syntax
npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:397:12)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "F:\\Programlar\\node.exe" "C:\\Users\\Seda\\Desktop\\huseyinsavran\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd C:\Users\Seda\Desktop\huseyinsavran\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.10.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Seda\AppData\Local\npm-cache\_logs\2021-10-14T21_24_40_991Z-debug.log
PS C:\Users\Seda\Desktop\huseyinsavran>

报错截图

报错截图

解决方案

该报错的根因是旧版node-sass与当前Node 16版本不兼容,node-sass编译需要依赖Python 2.7环境,当前系统默认Python为Python 3版本,语法不匹配导致编译失败,并非eslint相关依赖问题。

优先方案(无需配置编译环境,兼容性最好)

将node-sass替换为完全兼容的纯JS实现dart-sass,无需编译即可使用,使用方式和node-sass完全一致:

  1. 删除项目根目录下的node_modules文件夹、package-lock.json文件
  2. 执行命令卸载旧依赖:npm uninstall node-sass sass-loader
  3. 执行命令安装新依赖:npm install sass sass-loader@10 --save-dev
  4. 重新执行npm install安装剩余依赖后即可正常启动项目

备选方案(必须保留node-sass时使用)

对齐node-sass版本和编译环境:

  1. 安装Python 2.7,安装过程中勾选「添加到系统PATH」选项
  2. 执行命令配置node-gyp的Python路径:npm config set python python2.7
  3. 安装适配Node 16的node-sass版本:npm install node-sass@6.0.1 sass-loader@10 --save-dev
  4. 重新执行npm install即可

内容的提问来源于stack exchange,提问作者Seda Yılmaz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.30 10:57:00