npm/node-sass安装依赖报错

Failed to resolve loader: sass-loader

bash 复制代码
 ERROR  Failed to compile with 1 error                                                                                                                                           10:49:21

Failed to resolve loader: sass-loader
You may need to install it.

npm ERR! code E404

bash 复制代码
$ npm install nodes-sass --save-dev --legacy-peer-deps
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/nodes-sass - Not found
npm ERR! 404
npm ERR! 404  'nodes-sass@*' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! A complete log of this run can be found in:

修改镜像地址: --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/

bash 复制代码
$ npm i node-sass --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/ --legacy-peer-deps
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm WARN deprecated eslint-loader@2.2.1: This loader has been deprecated. Please use eslint-webpack-plugin
npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.

added 338 packages, and changed 95 packages in 2m

118 packages are looking for funding
  run `npm fund` for details
bash 复制代码
$ npm i sass-loader --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/ --legacy-peer-deps
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

added 1 package in 2m

118 packages are looking for funding
  run `npm fund` for details

最终安装完成

bash 复制代码
$ node -v
v16.16.0

package.json

bash 复制代码
"dependencies": {
	#...略其它...
    "node-sass": "^9.0.0",
    "sass-loader": "^13.3.2",
 }

参照更多: https://juejin.cn/post/7029193821955031054

相关推荐
聪明蛋子哟1 小时前
Stagehand v3多语言SDK:Python/Go/Rust/Java下的浏览器自动化统一方案
python·golang·rust
小灰灰搞电子6 小时前
Rust+Slint 实现温度计源码分享
前端·rust·slint
GitLqr6 小时前
2026 Bun 全新姿态:从 Zig 到 Rust 的“暴力”重构与生态大爆发
rust·node.js·bun
小灰灰搞电子11 小时前
Rust+Slint 实现动态加载效果源码分享
rust·slint·等待控件
Thneonl13 小时前
让恢复动作敢按下去:dry-run、审批门、自动回滚与 mutable twin
rust·kubernetes
阿萨德528号15 小时前
npm 包发布实战指南:从零发布、更新迭代到版本治理
前端·npm·策略模式
程序员爱钓鱼16 小时前
Rust where详解:让泛型与Trait约束更加清晰
前端·后端·rust
Flynt1 天前
就编译了一下代码,浏览器密码没了——Rust 生态遭遇史上最狠供应链攻击
安全·rust·开源
NutShell Wang2 天前
Rust 1.97 实战迁移:v0 符号重整、Cargo 警告治理与位运算新 API
人工智能·后端·性能优化·rust·vibe coding