- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我收到这个错误:
如果你想包含一个 polyfill,你需要: - 添加一个后备 'resolve.fallback: { "path": require.resolve("path-browserify") }' - 安装 'path-browserify '
:
(base) raphy@pc:~/NEW-Raphy-Template$ yarn start
yarn run v1.22.18
$ yarn run build && ELECTRON_DISABLE_SECURITY_WARNINGS=true electron ./dist/main/main.js
$ npx webpack --config ./webpack.config.js
asset main.js 11.2 MiB [compared for emit] (name: main)
runtime modules 793 bytes 4 modules
javascript modules 8.33 MiB
modules by path ./node_modules/ 8.26 MiB
cacheable modules 8.26 MiB 1402 modules
optional modules 3.24 KiB [optional] 3 modules
modules by path ./src/ 74.6 KiB 18 modules
+ 28 modules
json modules 1.19 MiB
modules by path ./node_modules/har-schema/lib/ 6.93 KiB 18 modules
modules by path ./node_modules/cheerio/ 96.9 KiB 16 modules
modules by path ./node_modules/@postlight/mercury-parser/ 261 KiB 9 modules
modules by path ./node_modules/iconv-lite/ 86.7 KiB 8 modules
modules by path ./node_modules/ajv/lib/ 5.58 KiB 3 modules
modules by path ./node_modules/whatwg-encoding/lib/ 5.33 KiB 2 modules
+ 7 modules
WARNING in ./node_modules/jsdom/lib/jsdom/utils.js 186:21-40
Critical dependency: the request of a dependency is an expression
@ ./node_modules/jsdom/lib/jsdom/browser/Window.js 8:26-45
@ ./node_modules/jsdom/lib/api.js 14:15-51
@ ./node_modules/turndown/lib/turndown.es.js 527:16-38
@ ./node_modules/@postlight/mercury-parser/dist/mercury.js 11:38-57
@ ./src/main/main.ts 54:41-77
WARNING in ./node_modules/parse5/lib/index.js 55:23-49
Critical dependency: the request of a dependency is an expression
@ ./node_modules/jsdom/lib/jsdom/browser/domtohtml.js 2:15-32
@ ./node_modules/jsdom/lib/api.js 15:22-61
@ ./node_modules/turndown/lib/turndown.es.js 527:16-38
@ ./node_modules/@postlight/mercury-parser/dist/mercury.js 11:38-57
@ ./src/main/main.ts 54:41-77
2 warnings have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
webpack 5.72.1 compiled with 2 warnings in 23433 ms
assets by path assets/css/ 1.25 MiB
assets by path assets/css/fonts/ 1.19 MiB 13 assets
assets by path assets/css/*.css 45.9 KiB 9 assets
assets by path assets/css/images/*.png 6.35 KiB
asset assets/css/images/marker-icon-2x.png 2.41 KiB [compared for emit] [from: src/assets/css/images/marker-icon-2x.png] [copied]
+ 4 assets
asset assets/css/App.scss 5.26 KiB [compared for emit] [from: src/assets/css/App.scss] [copied]
asset assets/css/postcss/app.pcss 721 bytes [compared for emit] [from: src/assets/css/postcss/app.pcss] [copied]
assets by path *.js 5.66 MiB
asset app.js 5.66 MiB [compared for emit] (name: app)
asset style.js 2.72 KiB [compared for emit] (name: style)
assets by path *.css 79.3 KiB
asset app.css 41.5 KiB [compared for emit] (name: app)
asset style.css 37.8 KiB [compared for emit] (name: style)
asset index.html 617 bytes [compared for emit]
Entrypoint app 5.7 MiB = app.css 41.5 KiB app.js 5.66 MiB
Entrypoint style 40.5 KiB = style.css 37.8 KiB style.js 2.72 KiB
orphan modules 286 KiB [orphan] 159 modules
runtime modules 1.59 KiB 7 modules
modules by path ./node_modules/ 3.87 MiB (javascript) 18.3 KiB (css/mini-extract) 1599 modules
modules by path ./src/ 39.1 KiB (javascript) 41.5 KiB (css/mini-extract)
javascript modules 39.1 KiB
modules by path ./src/app/ 35.3 KiB 14 modules
+ 4 modules
css modules 41.5 KiB
modules by path ./src/app/sections/ 1.43 KiB 2 modules
css ./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/app/styles/index.css 19.5 KiB [built] [code generated]
css ./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/assets/css/global.css 19.7 KiB [built] [code generated]
css ./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/app/components/Sidebar.css 940 bytes [built] [code generated]
ERROR in ./node_modules/file-url/index.js 2:13-28
Module not found: Error: Can't resolve 'path' in '/home/raphy/NEW-Raphy-Template/node_modules/file-url'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "path": false }
resolve 'path' in '/home/raphy/NEW-Raphy-Template/node_modules/file-url'
Parsed request is a module
using description file: /home/raphy/NEW-Raphy-Template/node_modules/file-url/package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
/home/raphy/NEW-Raphy-Template/node_modules/file-url/node_modules doesn't exist or is not a directory
/home/raphy/NEW-Raphy-Template/node_modules/node_modules doesn't exist or is not a directory
looking for modules in /home/raphy/NEW-Raphy-Template/node_modules
single file module
using description file: /home/raphy/NEW-Raphy-Template/package.json (relative path: ./node_modules/path)
no extension
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/NEW-Raphy-Template/node_modules/path doesn't exist
.jsx
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/NEW-Raphy-Template/node_modules/path.jsx doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/NEW-Raphy-Template/node_modules/path.js doesn't exist
.tsx
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/NEW-Raphy-Template/node_modules/path.tsx doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/NEW-Raphy-Template/node_modules/path.ts doesn't exist
/home/raphy/NEW-Raphy-Template/node_modules/path doesn't exist
looking for modules in /home/raphy/node_modules
single file module
No description file found in /home/raphy/node_modules or above
no extension
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/node_modules/path doesn't exist
.jsx
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/node_modules/path.jsx doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/node_modules/path.js doesn't exist
.tsx
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/node_modules/path.tsx doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/node_modules/path.ts doesn't exist
/home/raphy/node_modules/path doesn't exist
/home/node_modules doesn't exist or is not a directory
/node_modules doesn't exist or is not a directory
@ ./src/app/sections/infobasket/Infobasket.js 83:16-35
@ ./src/app/components/App.tsx 18:41-85
@ ./src/app/index.tsx 7:34-61
webpack 5.72.1 compiled with 1 error in 23411 ms
但是如果我在 resolve
中添加那些 fallback
:
// main process
var main_config = {
mode: isEnvProduction ? 'production' : 'development',
entry: './src/main/main.ts',
target: 'electron-main',
resolve: {
fallback: { 'path': require.resolve('path-browserify') },
extensions: ['.jsx', '.js', 'ts'],
},
我得到了同样的错误:
(base) raphy@pc:~/NEW-Raphy-Template$ yarn start
yarn run v1.22.18
$ yarn run build && ELECTRON_DISABLE_SECURITY_WARNINGS=true electron ./dist/main/main.js
$ npx webpack --config ./webpack.config.js
asset main.js 11.2 MiB [compared for emit] (name: main)
runtime modules 793 bytes 4 modules
javascript modules 8.33 MiB
modules by path ./node_modules/ 8.26 MiB
cacheable modules 8.26 MiB 1402 modules
optional modules 3.24 KiB [optional] 3 modules
modules by path ./src/ 74.6 KiB 18 modules
+ 28 modules
json modules 1.19 MiB
modules by path ./node_modules/har-schema/lib/ 6.93 KiB 18 modules
modules by path ./node_modules/cheerio/ 96.9 KiB 16 modules
modules by path ./node_modules/@postlight/mercury-parser/ 261 KiB 9 modules
modules by path ./node_modules/iconv-lite/ 86.7 KiB 8 modules
modules by path ./node_modules/ajv/lib/ 5.58 KiB 3 modules
modules by path ./node_modules/whatwg-encoding/lib/ 5.33 KiB 2 modules
+ 7 modules
WARNING in ./node_modules/jsdom/lib/jsdom/utils.js 186:21-40
Critical dependency: the request of a dependency is an expression
@ ./node_modules/jsdom/lib/jsdom/browser/Window.js 8:26-45
@ ./node_modules/jsdom/lib/api.js 14:15-51
@ ./node_modules/turndown/lib/turndown.es.js 527:16-38
@ ./node_modules/@postlight/mercury-parser/dist/mercury.js 11:38-57
@ ./src/main/main.ts 54:41-77
WARNING in ./node_modules/parse5/lib/index.js 55:23-49
Critical dependency: the request of a dependency is an expression
@ ./node_modules/jsdom/lib/jsdom/browser/domtohtml.js 2:15-32
@ ./node_modules/jsdom/lib/api.js 15:22-61
@ ./node_modules/turndown/lib/turndown.es.js 527:16-38
@ ./node_modules/@postlight/mercury-parser/dist/mercury.js 11:38-57
@ ./src/main/main.ts 54:41-77
2 warnings have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
webpack 5.72.1 compiled with 2 warnings in 23467 ms
assets by path assets/css/ 1.25 MiB
assets by path assets/css/fonts/ 1.19 MiB 13 assets
assets by path assets/css/*.css 45.9 KiB 9 assets
assets by path assets/css/images/*.png 6.35 KiB
asset assets/css/images/marker-icon-2x.png 2.41 KiB [compared for emit] [from: src/assets/css/images/marker-icon-2x.png] [copied]
+ 4 assets
asset assets/css/App.scss 5.26 KiB [compared for emit] [from: src/assets/css/App.scss] [copied]
asset assets/css/postcss/app.pcss 721 bytes [compared for emit] [from: src/assets/css/postcss/app.pcss] [copied]
assets by path *.js 5.66 MiB
asset app.js 5.66 MiB [compared for emit] (name: app)
asset style.js 2.72 KiB [compared for emit] (name: style)
assets by path *.css 79.3 KiB
asset app.css 41.5 KiB [compared for emit] (name: app)
asset style.css 37.8 KiB [compared for emit] (name: style)
asset index.html 617 bytes [compared for emit]
Entrypoint app 5.7 MiB = app.css 41.5 KiB app.js 5.66 MiB
Entrypoint style 40.5 KiB = style.css 37.8 KiB style.js 2.72 KiB
orphan modules 286 KiB [orphan] 159 modules
runtime modules 1.59 KiB 7 modules
modules by path ./node_modules/ 3.87 MiB (javascript) 18.3 KiB (css/mini-extract) 1599 modules
modules by path ./src/ 39.1 KiB (javascript) 41.5 KiB (css/mini-extract)
javascript modules 39.1 KiB
modules by path ./src/app/ 35.3 KiB 14 modules
+ 4 modules
css modules 41.5 KiB
modules by path ./src/app/sections/ 1.43 KiB 2 modules
css ./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/app/styles/index.css 19.5 KiB [built] [code generated]
css ./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/assets/css/global.css 19.7 KiB [built] [code generated]
css ./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/app/components/Sidebar.css 940 bytes [built] [code generated]
ERROR in ./node_modules/file-url/index.js 2:13-28
Module not found: Error: Can't resolve 'path' in '/home/raphy/NEW-Raphy-Template/node_modules/file-url'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "path": false }
resolve 'path' in '/home/raphy/NEW-Raphy-Template/node_modules/file-url'
Parsed request is a module
using description file: /home/raphy/NEW-Raphy-Template/node_modules/file-url/package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
/home/raphy/NEW-Raphy-Template/node_modules/file-url/node_modules doesn't exist or is not a directory
/home/raphy/NEW-Raphy-Template/node_modules/node_modules doesn't exist or is not a directory
looking for modules in /home/raphy/NEW-Raphy-Template/node_modules
single file module
using description file: /home/raphy/NEW-Raphy-Template/package.json (relative path: ./node_modules/path)
no extension
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/NEW-Raphy-Template/node_modules/path doesn't exist
.jsx
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/NEW-Raphy-Template/node_modules/path.jsx doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/NEW-Raphy-Template/node_modules/path.js doesn't exist
.tsx
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/NEW-Raphy-Template/node_modules/path.tsx doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/NEW-Raphy-Template/node_modules/path.ts doesn't exist
/home/raphy/NEW-Raphy-Template/node_modules/path doesn't exist
looking for modules in /home/raphy/node_modules
single file module
No description file found in /home/raphy/node_modules or above
no extension
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/node_modules/path doesn't exist
.jsx
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/node_modules/path.jsx doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/node_modules/path.js doesn't exist
.tsx
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/node_modules/path.tsx doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
/home/raphy/node_modules/path.ts doesn't exist
/home/raphy/node_modules/path doesn't exist
/home/node_modules doesn't exist or is not a directory
/node_modules doesn't exist or is not a directory
@ ./src/app/sections/infobasket/Infobasket.js 83:16-35
@ ./src/app/components/App.tsx 18:41-85
@ ./src/app/index.tsx 7:34-61
webpack 5.72.1 compiled with 1 error in 23445 ms
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
那么....如何在webpack.config.js
中正确解析
?
最佳答案
已解决。
只是添加
resolve: {
fallback: { 'path': require.resolve('path-browserify') },
extensions: ['.jsx', '.js', '.tsx', '.ts'],
}
同样在webpack配置
的renderer
部分
关于webpack-5 - 如何在 webpack 中使用 fallback : { 'path' : require. resolve ('path-browserify' )?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72321500/
我有 带有插件系统的软件包。每个插件都是一个包 可以通过调用 use 方法来加载插件。并将插件导出作为参数传递: package = require('thePackage').use( requir
我知道 browserify 可以通过转换来使用 UMD 模块,但是当我想使用 browserify 构建一个库时,我该如何构建一个 UMD 模块?我可以使用任何转换吗? 最佳答案 如果您想使用 br
我有 third-party-module-b使用 third_party_module_a全局并拥有 require('third-party-module-a'); 在入口点。 问题是third-
我正在使用 Browserify 和 Grunt 来捆绑我们的 RendrJS webapp。我想分析这个包,看看它包含哪些模块,看看是否有多余的代码。这可能会发生,因为在 Rendr 中,一些 js
在 browserify 手册中,exclude part ,它给出了一个使用排除的例子: $ npm install jquery $ browserify -r jquery --standalo
在我的前端代码中,我使用 require()引入依赖于不同版本的 Underscore.js 的库。结果,当我使用 browserify 将所有内容捆绑在一起时,输出包含多个 Underscore 副
我正在使用 SpineJS(它导出一个 commonjs 模块),它需要在全局范围内可用,因为我在任何地方都使用它,但似乎我必须这样做 Spine = require('spine')在每个使用 Sp
假设我有一个模块,其源代码不是 ECMA 5(例如,它是 Coffescript 或 Typescript 或其他),并且以带有源映射的编译形式分发。如何将此源映射包含在 Browserify 包中?
我想创建一个独立的 browserify 包,它将导出的对象直接附加到 window 对象,而不是嵌套在附加到 window 的包装器对象下。 这样做,browserify 会忽略窗口: browse
当您将代码与 Browserify 捆绑在一起时,您使用的每个模 block 都内联在结果输出中,并标有其本地文件路径。因此,您可以在捆绑代码中看到文件路径字符串。 但理论上,这些字符串都可以重写为“
我需要将一些模块强制放入我的包中,因为它们是通过如下代码动态需要的: var moduleName = "someModule"; var myModule = require(moduleName)
我正在尝试通过使用 browserify-shim 将某些模块从包中填充出来来重构使用 Browserify 的库。具体来说,该库使用 require("codemirror") 但我想提供一个不包含
我在新项目中使用了 browserify。到目前为止,它运行得非常好。 不过我有一个大问题。如何分别调试每个 js 文件。它将所有文件捆绑在一起,并在发生错误时指向捆绑。 我正在使用 chrome 和
来自 watchify 的文档, 我懂了: When creating the browserify instance b you MUST set these properties in the c
使用 browserify,我试图要求一个已经浏览器化的模块,但是包无法解析已经浏览器化的模块。 例如,我有一个文件 bundle-1.js 已与命令捆绑在一起: browserify -r ./bu
关于 external requires 的 Browserify 文档部分展示如何使包中的模块可用于全局环境: browserify -r through -r duplexer -r ./my-f
现在,gulp-browserify is no longer supported我正在寻找一个简单的教程,如何现在使用带有 gulp 的 browserify。 This似乎是一种选择,但它仍然相当
我是 Nodejs 和 browserify 的新手。我从这个开始link . 我有文件 main.js,其中包含此代码 var unique = require('uniq'); var data
我最近从 Grunt 过渡到 Gulp。但是我还是个新手,谁能告诉我使用 Gulp-Browserify 和只使用 Browserify 之间的区别是什么? 我知道 Gulp-Browserify 现
描述:我有 package.json 和 bower.json 用于处理我当前架构中的依赖项。我应该在哪个文件中添加 “jquery.slider(版本 1.1.0)”以及怎么做? 目前,我已经在 b
我是一名优秀的程序员,十分优秀!