关于cnpm run dev报错

关于cnpm run dev报错

问题描述:

老师 cnpm install&cnpm run dev 报错 无法安装依赖 且无法启动 这种应该如何解决?

相关截图:

https://img1.sycdn.imooc.com//climg/62c2ce650904f0c819101238.jpg

尝试过的解决方式:

降级为v12

升级为v14

都无法解决

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
bobby 2022-07-05 14:17:57

https://img1.sycdn.imooc.com//climg/62c3d78e09625aff02090102.jpg 我这里的版本 刚才试过了 可以运行

  • 提问者 清羽绝弦 #1

    https://img1.sycdn.imooc.com//climg/62c3d99d0907034119001286.jpg


    还是不太行  似乎是因为npm的版本原因? 

    我是不是还要把npm的版本升级一下

    2022-07-05 14:27:27
  • bobby 回复 提问者 清羽绝弦 #2

    一般 nmp https://img1.sycdn.imooc.com//climg/62c64c9b098a3ed505380255.jpg 你看看是不是这些版本,如果不行就留个qq 我加你看看

    2022-07-07 11:02:02
  • 404_ #3

    老师我用得就是这个版本

    [root@docker1 node_modules]# node -v

    v14.17.0

    [root@docker1 node_modules]# npm version

    {

      'mxshop-admin': '1.0.0',

      npm: '6.14.13',

      ares: '1.17.1',

      brotli: '1.0.9',

      cldr: '38.1',

      icu: '68.2',

      llhttp: '2.1.3',

      modules: '83',

      napi: '8',

      nghttp2: '1.42.0',

      node: '14.17.0',

      openssl: '1.1.1k',

      tz: '2020d',

      unicode: '13.0',

      uv: '1.41.0',

      v8: '8.4.371.23-node.63',

      zlib: '1.2.11'

    }

    但是在启动 mall-master 报错了:

    [root@docker1 mall-master]# cnpm run dev


    > mxshop-admin@1.0.0 dev

    > webpack-dev-server --inline --progress --config build/webpack.dev.conf.js


     94% asset optimization                                                                  



     ERROR  Failed to compile with 11 errors                                                                                                                                                               上午5:09:59


     error  in ./src/styles/index.scss


    Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.

        at Object.sassLoader (/app/bobby/mall-master/node_modules/sass-loader/lib/loader.js:31:19)


     @ ./src/styles/index.scss 4:14-203 13:3-17:5 14:22-211

     @ ./src/main.js

     @ multi (webpack)-dev-server/client?http://localhost:8090 webpack/hot/dev-server ./src/main.js

    我已经安装了了node-sass版本,更新信息如下

    [root@docker1 node_modules]# cnpm install node-sass

    ✔ Installed 1 packages

    ✔ Linked 219 latest versions

    [1/1] scripts.install node-sass@latest run "node scripts/install.js", root: "/app/bobby/mall-master/node_modules/node_modules/_node-sass@7.0.1@node-sass"

    Downloading binary from https://cdn.npmmirror.com/binaries/node-sass/v7.0.1/linux-x64-83_binding.node

    Download complete

    Binary saved to /app/bobby/mall-master/node_modules/node_modules/_node-sass@7.0.1@node-sass/vendor/linux-x64-83/binding.node

    Caching binary to /root/.npminstall_tarball/node-sass/7.0.1/linux-x64-83_binding.node

    [1/1] scripts.install node-sass@latest finished in 1s

    [1/1] scripts.postinstall node-sass@latest run "node scripts/build.js", root: "/app/bobby/mall-master/node_modules/node_modules/_node-sass@7.0.1@node-sass"

    Binary found at /app/bobby/mall-master/node_modules/node_modules/_node-sass@7.0.1@node-sass/vendor/linux-x64-83/binding.node

    Testing binary

    Binary is fine

    [1/1] scripts.postinstall node-sass@latest finished in 333ms

    ✔ Run 1 scripts

    deprecate node-sass@7.0.1 › request@^2.88.0 request has been deprecated, see https://github.com/request/request/issues/3142

    deprecate node-sass@7.0.1 › request@2.88.2 › har-validator@~5.1.3 this library is no longer supported

    deprecate node-sass@7.0.1 › request@2.88.2 › uuid@^3.3.2 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.

    ✔ All packages installed (243 packages installed from npm registry, used 8s(network 6s), speed 919.64KB/s, json 219(1.01MB), tarball 4.51MB, manifests cache hit 0, etag hit 0 / miss 0)


    但是最后还是不行。

    2022-07-16 21:18:08
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师