当前位置: 首页 > 知识库问答 >
问题:

webpack5打包报错怎么解决?

卫嘉谊
2023-04-26

webpack5 打包时候会报几个这种问题,怎么解决

      ModuleNotFoundError: Module not found: Error: Can't resolve 'osx-temperature-sensor' in '/Users/mcgee0731/boss-hi-desk/node_modules/systeminformation/lib'
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/lib/Compilation.js:2016:28
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/lib/NormalModuleFactory.js:805:13
          at eval (eval at create (/Users/mcgee0731/boss-hi-desk/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/lib/NormalModuleFactory.js:272:22
          at eval (eval at create (/Users/mcgee0731/boss-hi-desk/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/lib/NormalModuleFactory.js:436:22
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/lib/NormalModuleFactory.js:118:11
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/lib/NormalModuleFactory.js:677:25
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/lib/NormalModuleFactory.js:881:8
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/lib/NormalModuleFactory.js:1001:5
          at /Users/mcgee0731/boss-hi-desk/node_modules/neo-async/async.js:6883:13
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/lib/NormalModuleFactory.js:984:45
          at finishWithoutResolve (/Users/mcgee0731/boss-hi-desk/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:320:11)
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:394:15
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:443:5
          at eval (eval at create (/Users/mcgee0731/boss-hi-desk/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:443:5
          at eval (eval at create (/Users/mcgee0731/boss-hi-desk/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:87:43
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:443:5
          at eval (eval at create (/Users/mcgee0731/boss-hi-desk/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:443:5
          at eval (eval at create (/Users/mcgee0731/boss-hi-desk/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:443:5
          at eval (eval at create (/Users/mcgee0731/boss-hi-desk/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:443:5
          at eval (eval at create (/Users/mcgee0731/boss-hi-desk/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:87:43
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:443:5
          at eval (eval at create (/Users/mcgee0731/boss-hi-desk/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:443:5
          at eval (eval at create (/Users/mcgee0731/boss-hi-desk/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
          at /Users/mcgee0731/boss-hi-desk/node_modules/webpack/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js:41:15
          at processTicksAndRejections (node:internal/process/task_queues:82:21)
      resolve 'osx-temperature-sensor' in '/Users/mcgee0731/boss-hi-desk/node_modules/systeminformation/lib'
        Parsed request is a module
        using description file: /Users/mcgee0731/boss-hi-desk/node_modules/systeminformation/package.json (relative path: ./lib)
          Field 'browser' doesn't contain a valid alias configuration
          resolve as module
            /Users/mcgee0731/boss-hi-desk/node_modules/systeminformation/lib/modules doesn't exist or is not a directory
            /Users/mcgee0731/boss-hi-desk/node_modules/systeminformation/lib/node_modules doesn't exist or is not a directory
            /Users/mcgee0731/boss-hi-desk/node_modules/systeminformation/lib/cell doesn't exist or is not a directory
            /Users/mcgee0731/boss-hi-desk/node_modules/systeminformation/modules doesn't exist or is not a directory
            /Users/mcgee0731/boss-hi-desk/node_modules/systeminformation/node_modules doesn't exist or is not a directory
            /Users/mcgee0731/boss-hi-desk/node_modules/systeminformation/cell doesn't exist or is not a directory
            /Users/mcgee0731/boss-hi-desk/node_modules/modules doesn't exist or is not a directory
            /Users/mcgee0731/boss-hi-desk/node_modules/node_modules doesn't exist or is not a directory
            /Users/mcgee0731/boss-hi-desk/node_modules/cell doesn't exist or is not a directory
            looking for modules in /Users/mcgee0731/boss-hi-desk/modules
              single file module
                using description file: /Users/mcgee0731/boss-hi-desk/package.json (relative path: ./modules/osx-temperature-sensor)
                  no extension
                    Field 'browser' doesn't contain a valid alias configuration
                    /Users/mcgee0731/boss-hi-desk/modules/osx-temperature-sensor doesn't exist
                  .js
                    Field 'browser' doesn't contain a valid alias configuration
                    /Users/mcgee0731/boss-hi-desk/modules/osx-temperature-sensor.js doesn't exist
                  .vue
                    Field 'browser' doesn't contain a valid alias configuration
                    /Users/mcgee0731/boss-hi-desk/modules/osx-temperature-sensor.vue doesn't exist
                  .json
                    Field 'browser' doesn't contain a valid alias configuration
                    /Users/mcgee0731/boss-hi-desk/modules/osx-temperature-sensor.json doesn't exist
                  .node
                    Field 'browser' doesn't contain a valid alias configuration
                    /Users/mcgee0731/boss-hi-desk/modules/osx-temperature-sensor.node doesn't exist
                  .ts
                    Field 'browser' doesn't contain a valid alias configuration
                    /Users/mcgee0731/boss-hi-desk/modules/osx-temperature-sensor.ts doesn't exist
              /Users/mcgee0731/boss-hi-desk/modules/osx-temperature-sensor doesn't exist
            looking for modules in /Users/mcgee0731/boss-hi-desk/node_modules
              single file module
                using description file: /Users/mcgee0731/boss-hi-desk/package.json (relative path: ./node_modules/osx-temperature-sensor)
                  no extension
                    Field 'browser' doesn't contain a valid alias configuration
                    /Users/mcgee0731/boss-hi-desk/node_modules/osx-temperature-sensor doesn't exist
                  .js
                    Field 'browser' doesn't contain a valid alias configuration
                    /Users/mcgee0731/boss-hi-desk/node_modules/osx-temperature-sensor.js doesn't exist
                  .vue
                    Field 'browser' doesn't contain a valid alias configuration
                    /Users/mcgee0731/boss-hi-desk/node_modules/osx-temperature-sensor.vue doesn't exist
                  .json
                    Field 'browser' doesn't contain a valid alias configuration
                    /Users/mcgee0731/boss-hi-desk/node_modules/osx-temperature-sensor.json doesn't exist
                  .node
                    Field 'browser' doesn't contain a valid alias configuration
                    /Users/mcgee0731/boss-hi-desk/node_modules/osx-temperature-sensor.node doesn't exist
                  .ts
                    Field 'browser' doesn't contain a valid alias configuration
                    /Users/mcgee0731/boss-hi-desk/node_modules/osx-temperature-sensor.ts doesn't exist
              /Users/mcgee0731/boss-hi-desk/node_modules/osx-temperature-sensor doesn't exist
            /Users/mcgee0731/boss-hi-desk/cell doesn't exist or is not a directory
            /Users/mcgee0731/modules doesn't exist or is not a directory
            /Users/mcgee0731/node_modules doesn't exist or is not a directory
            /Users/mcgee0731/cell doesn't exist or is not a directory
            /Users/modules doesn't exist or is not a directory
            /Users/node_modules doesn't exist or is not a directory
            /Users/cell doesn't exist or is not a directory
            /modules doesn't exist or is not a directory
            /node_modules doesn't exist or is not a directory
            /cell doesn't exist or is not a directory,

共有2个答案

严正初
2023-04-26

image.png
webpack的alias配置了lib没有

resolve: {
    alias: {
      '@': path.resolve(__dirname, 'lib'),
    },
  }
尤夕
2023-04-26

这个错误信息表示 Node 在 '/Users/mcgee0731/boss-hi-desk/node_modules/systeminformation/lib' 目录下找不到 'osx-temperature-sensor' 模块。

npm install osx-temperature-sensor
 类似资料:
  • vue3、vite项目本地运行正常,打包报一堆错,应该是type-check的报错,应该怎么解决? 无

  • vue3+vite打包的时候,报错Access is denied,请问怎么解决啊?重新装了node_modules包,用nvm试了npm的几个版本都不行

  • 创建的测试证书打包打包报错怎么解决呢?

  • 由于云之家提供的jar, 在maven上找不到,我只能在idea上直接导入。本地上能够运行,但想打包发布到服务器上。idea就提示"程序包com.yunzhijia.cloudflow不存在"。这种情况请问得怎么解决??

  • 有没有大佬来帮我看一看,是关于github actions的,我在实现一个推送代码到指定分支上时,会自动触发在远程目标服务器上面部署运行springboot项目,但是每一次运行到以下代码的时候: 它就会一直卡在这里。但是事实上,这一个项目是被正确运行了,监听端口也有信息,但是工作流中会报错: 我有一点不明白,部署成功之后,不就是应该断开ssh连接吗?有没有大佬解决一下? 因为这个地方报错,所以它工

  • gulp版本是4.0.2 babel版本是6.23.0 打完没出现错误,但是到浏览器就出现