Webpack搭建错误集

Webpack搭建错误集

1.[webpack-cli] Error: Cannot find module 'lodash'

PS D:\Working\TypeScript\path3> npm run build

> build  
> webpack

[webpack-cli] Failed to load 'D:\Working\TypeScript\path3\webpack.config.js' config
[webpack-cli] Error: Cannot find module 'lodash'
Require stack:
- D:\Working\TypeScript\path3\node_modules\_html-webpack-plugin@5.5.0@html-webpack-plugin\index.js
- D:\Working\TypeScript\path3\webpack.config.js
- D:\Working\TypeScript\path3\node_modules\_webpack-cli@4.10.0@webpack-cli\lib\webpack-cli.js     
- D:\Working\TypeScript\path3\node_modules\_webpack-cli@4.10.0@webpack-cli\lib\bootstrap.js       
- D:\Working\TypeScript\path3\node_modules\_webpack-cli@4.10.0@webpack-cli\bin\cli.js
- D:\Working\TypeScript\path3\node_modules\_webpack@5.74.0@webpack\bin\webpack.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (D:\Working\TypeScript\path3\node_modules\_html-webpack-plugin@5.5.0@html-webpack-plugin\index.js:15:11)
PS D:\Working\TypeScript\path3> cnpm i -D lodash
(node:14932) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
√ Installed 1 packages
√ Linked 1 latest versions
√ Run 0 scripts
√ All packages installed (1 packages installed from npm registry, used 10s(network 10s), speed 1.35KB/s, json 1(13.9KB), tarball 0B, manifests cache hit 0, etag hit 0 / miss 1)
PS D:\Working\TypeScript\path3> npm run build

> build  
> webpack

[webpack-cli] Failed to load 'D:\Working\TypeScript\path3\webpack.config.js' config
[webpack-cli] Error: Cannot find module 'pretty-error'
Require stack:
- D:\Working\TypeScript\path3\node_modules\_html-webpack-plugin@5.5.0@html-webpack-plugin\lib\errors.js
- D:\Working\TypeScript\path3\node_modules\_html-webpack-plugin@5.5.0@html-webpack-plugin\index.js
- D:\Working\TypeScript\path3\webpack.config.js
- D:\Working\TypeScript\path3\node_modules\_webpack-cli@4.10.0@webpack-cli\lib\webpack-cli.js
- D:\Working\TypeScript\path3\node_modules\_webpack-cli@4.10.0@webpack-cli\lib\bootstrap.js
- D:\Working\TypeScript\path3\node_modules\_webpack-cli@4.10.0@webpack-cli\bin\cli.js
- D:\Working\TypeScript\path3\node_modules\_webpack@5.74.0@webpack\bin\webpack.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (D:\Working\TypeScript\path3\node_modules\_html-webpack-plugin@5.5.0@html-webpack-plugin\lib\errors.js:3:21)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'D:\\Working\\TypeScript\\path3\\node_modules\\_html-webpack-plugin@5.5.0@html-webpack-plugin\\lib\\errors.js',
    'D:\\Working\\TypeScript\\path3\\webpack.config.js',
    'D:\\Working\\TypeScript\\path3\\node_modules\\_webpack-cli@4.10.0@webpack-cli\\lib\\webpack-cli.js',
    'D:\\Working\\TypeScript\\path3\\node_modules\\_webpack-cli@4.10.0@webpack-cli\\lib\\bootstrap.js',
    'D:\\Working\\TypeScript\\path3\\node_modules\\_webpack-cli@4.10.0@webpack-cli\\bin\\cli.js',
    'D:\\Working\\TypeScript\\path3\\node_modules\\_webpack@5.74.0@webpack\\bin\\webpack.js'
  ]
}
PS D:\Working\TypeScript\path3> cnpm i -D pretty-error
(node:3996) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
√ Installed 1 packages
√ Linked 1 latest versions
√ Run 0 scripts
√ All packages installed (used 113ms(network 107ms), speed 0B/s, json 0(0B), tarball 0B, manifests cache hit 1, etag hit 1 / miss 0)
PS D:\Working\TypeScript\path3> npm run build

> build
> webpack

[webpack-cli] Failed to load 'D:\Working\TypeScript\path3\webpack.config.js' config
[webpack-cli] Error: Cannot find module 'renderkid'
Require stack:
- D:\Working\TypeScript\path3\node_modules\_pretty-error@4.0.0@pretty-error\lib\PrettyError.js
- D:\Working\TypeScript\path3\node_modules\_html-webpack-plugin@5.5.0@html-webpack-plugin\lib\errors.js
- D:\Working\TypeScript\path3\node_modules\_html-webpack-plugin@5.5.0@html-webpack-plugin\index.js
- D:\Working\TypeScript\path3\webpack.config.js
- D:\Working\TypeScript\path3\node_modules\_webpack-cli@4.10.0@webpack-cli\lib\webpack-cli.js
- D:\Working\TypeScript\path3\node_modules\_webpack-cli@4.10.0@webpack-cli\lib\bootstrap.js
- D:\Working\TypeScript\path3\node_modules\_webpack-cli@4.10.0@webpack-cli\bin\cli.js
- D:\Working\TypeScript\path3\node_modules\_webpack@5.74.0@webpack\bin\webpack.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (D:\Working\TypeScript\path3\node_modules\_pretty-error@4.0.0@pretty-error\lib\PrettyError.js:14:13)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'D:\\Working\\TypeScript\\path3\\node_modules\\_pretty-error@4.0.0@pretty-error\\lib\\PrettyError.js',
    'D:\\Working\\TypeScript\\path3\\node_modules\\_html-webpack-plugin@5.5.0@html-webpack-plugin\\lib\\errors.js',
    'D:\\Working\\TypeScript\\path3\\webpack.config.js',
    'D:\\Working\\TypeScript\\path3\\node_modules\\_webpack-cli@4.10.0@webpack-cli\\lib\\webpack-cli.js',
    'D:\\Working\\TypeScript\\path3\\node_modules\\_webpack-cli@4.10.0@webpack-cli\\lib\\bootstrap.js',
    'D:\\Working\\TypeScript\\path3\\node_modules\\_webpack-cli@4.10.0@webpack-cli\\bin\\cli.js',
    'D:\\Working\\TypeScript\\path3\\node_modules\\_webpack@5.74.0@webpack\\bin\\webpack.js'
  ]
}
PS D:\Working\TypeScript\path3> cnpm i -D renderkid   
(node:10992) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
√ Installed 1 packages
√ Linked 1 latest versions
√ Run 0 scripts
√ All packages installed (used 98ms(network 93ms), speed 0B/s, json 0(0B), tarball 0B, manifests cache hit 1, etag hit 1 / miss 0)
PS D:\Working\TypeScript\path3> npm run build      

> build
> webpack

asset index.html 216 bytes [emitted]
asset bander.js 117 bytes [emitted] [minimized] (name: main)
./src/index.ts 174 bytes [built] [code generated]
webpack 5.74.0 compiled successfully in 5108 ms
PS D:\Working\TypeScript\path3> 

2.Module not found: Error: Can't resolve './out' in 'D:\Working\TypeScript\path3\src'

PS D:\Working\TypeScript\path3> npm run build
Debugger attached.

> build
> webpack

Debugger attached.
assets by status 584 bytes [cached] 2 assets
./src/index.ts 158 bytes [built] [code generated]

ERROR in ./src/index.ts 1:0-28
Module not found: Error: Can't resolve './out' in 'D:\Working\TypeScript\path3\src'
resolve './out' in 'D:\Working\TypeScript\path3\src'
  using description file: D:\Working\TypeScript\path3\package.json (relative path: ./src)
    Field 'browser' doesn't contain a valid alias configuration
    using description file: D:\Working\TypeScript\path3\package.json (relative path: ./src/out)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        D:\Working\TypeScript\path3\src\out doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        D:\Working\TypeScript\path3\src\out.js doesn't exist
      .json
        Field 'browser' doesn't contain a valid alias configuration
      .wasm
        Field 'browser' doesn't contain a valid alias configuration
        D:\Working\TypeScript\path3\src\out.wasm doesn't exist
      as directory
        D:\Working\TypeScript\path3\src\out doesn't exist

webpack 5.74.0 compiled with 1 error in 7018 ms
Waiting for the debugger to disconnect...
Waiting for the debugger to disconnect...
PS D:\Working\TypeScript\path3>
// webpack中的所有的配置信息都应该写在module.exports 中
module.exports = {
    resolve: {
        extensions: ['.ts', '.js']
    }

}
posted @ 2022-11-05 17:46  Redskaber  阅读(2705)  评论(0)    收藏  举报