简体   繁体   English

找不到模块:错误:无法解析“加密”

[英]Module not found: Error: Can't resolve 'crypto'

I am getting the following list of errors when I run ng serve .我在运行ng serve时收到以下错误列表。

My package JSON is as follows:我的包JSON如下:

{   "name": "ProName",   "version": "0.0.0",   "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"   },   "private": true,   "dependencies": {
    "@angular-devkit/build-angular": "~0.12.0",
    "@angular/animations": "5.2.10",
    "@angular/common": "5.2.10",
    "@angular/compiler": "5.2.10",
    "@angular/compiler-cli": "5.2.10",
    "@angular/core": "5.2.10",
    "@angular/forms": "5.2.10",
    "@angular/platform-browser": "5.2.10",
    "@angular/platform-browser-dynamic": "5.2.10",
    "@angular/router": "5.2.10",
    "@types/dotenv": "^4.0.3",
    "@types/errorhandler": "0.0.32",
    "@types/express": "^4.16.0",
    "@types/node": "^10.5.1",
    "apostille-library": "^7.1.0",
    "core-js": "^2.5.4",
    "dotenv": "^6.0.0",
    "errorhandler": "^1.5.0",
    "express": "^4.16.0",
    "nem2-sdk": "^0.9.7",
    "rxjs": "~6.3.3",
    "stream": "0.0.2",
    "tslib": "^1.9.0",
    "typescript": "^2.9.2",
    "zone.js": "~0.8.26"   } }

The error I get:我得到的错误:

ERROR in./node_modules/aws-sign2/index.js Module not found: Error: Can't resolve 'crypto' in '/Users/MYPC/Documents/Myproj/ProName/node_modules/aws-sign2' ERROR in./node_modules/aws4/aws4.js Module not found: Error: Can't resolve 'crypto' in '/Users/MYPC/Documents/Myproj/ProName/node_modules/aws4' ERROR in./node_modules/ecc-jsbn/index.js Module not found: Error: Can't resolve 'crypto' in '/Users/MYPC/Documents/Myproj/ProName/node_modules/ecc-jsbn' ERROR in./node_modules/http-signature/lib/verify.js Module not found: Error: Can't resolve 'crypto' in '/Users/MYPC/Documents/Myproj/ProName/node_modules/http-signature/lib' ERROR in./node_modules/http-signature/lib/signer.js Module not found: Error: Can't resolve 'crypto' in '/Users/MYPC/Documents/Myproj/ProName/node_modules/http-signature/lib' ERROR in./node_modules/nem-sdk/build/external/nacl-fast.js Module not found: Error: Can't resolve 'crypto' in '/Users/MYPC/Documents/Myproj/ProName/node_modules/nem-sdk/build/external' ERROR in./node_ ./node_modules/aws-sign2/index.js 中的错误 找不到模块:错误:无法解析 '/Users/MYPC/Documents/Myproj/ProName/node_modules/aws-sign2' 中的 'crypto' 错误 in./node_modules /aws4/aws4.js 未找到模块:错误:无法解析 '/Users/MYPC/Documents/Myproj/ProName/node_modules/aws4' 中的 'crypto' 错误 in./node_modules/ecc-jsbn/index.js 模块未找到:错误:无法解析 '/Users/MYPC/Documents/Myproj/ProName/node_modules/ecc-jsbn' 中的 'crypto' 错误 in./node_modules/http-signature/lib/verify.js 未找到模块:错误:无法解析 '/Users/MYPC/Documents/Myproj/ProName/node_modules/http-signature/lib' 中的 'crypto' 错误 in./node_modules/http-signature/lib/signer.js 找不到模块:错误: 无法解析 '/Users/MYPC/Documents/Myproj/ProName/node_modules/http-signature/lib' 中的 'crypto' 错误 in./node_modules/nem-sdk/build/external/nacl-fast.js 模块不发现:错误:无法解析 '/Users/MYPC/Documents/Myproj/ProName/node_modules/nem-sdk/build/external' 中的 'crypto' 错误 in./node_ modules/nem-sdk/node_modules/aws-sign2/index.js模块/nem-sdk/node_modules/aws-sign2/index.js

I ran into a similar issue lately while trying to use another library ( tiff.js ) in a small project I was experimenting with.我最近在尝试在一个小项目中使用另一个库 ( tiff.js ) 时遇到了类似的问题。

The way I got around this was to add the following to my package.json file, right after the devDependencies section.我解决这个问题的方法是将以下内容添加到我的package.json文件中, devDependenciesdevDependencies部分之后。

"devDependencies": {
    ...
},
"browser": {
    "crypto": false
}

This didn't seem to have any adverse effect when trying to use the library in the application.尝试在应用程序中使用该库时,这似乎没有任何不利影响。

Adding this setting in tsconfig.json file under that project resolve this warning在该项目下的tsconfig.json文件中添加此设置可解决此警告

"compilerOptions": {
"baseUrl": "./",
"paths": {
  "crypto": [
    "node_modules/crypto-js"
  ]
}

I like R. Richards 's answer, but I thought it would be useful to provide some more information.我喜欢R. Richards的回答,但我认为提供更多信息会很有用。

This is a known issue with Angular, and the Angular CLI dev team seems to think it's a feature rather than a bug.这是 Angular 的一个已知问题,Angular CLI 开发团队似乎认为这是一个功能而不是错误。 I, as well as other developers in this issue thread , disagree.我以及此问题线程中的其他开发人员不同意。 Contributors to that thread provided several workaround fixes, but my project didn't compile successfully until I implemented R. Richards' solution.该线程的贡献者提供了几个解决方法修复,但我的项目在我实施 R. Richards 的解决方案之前没有成功编译。 I didn't revert the previous changes, though, so tacnoman 's and GrandSchtroumpf 's fixes may be of use to others.不过,我没有恢复以前的更改,因此tacnomanGrandSchtroumpf的修复可能对其他人有用。

Some, like clovis1122 here and others in that issue thread, have questioned why a web app would need access to these libraries and why the necessary tasks can't be completed on the server side instead.有些人,比如这里的clovis1122和该问题线程中的其他人,质疑为什么 Web 应用程序需要访问这些库,以及为什么不能在服务器端完成必要的任务。 I can't speak for everyone, but my use case is that, when authenticating a user account, Strapi responds with a JSON Web Token string that must be decoded by the client.我不能代表所有人,但我的用例是,在对用户帐户进行身份验证时,Strapi 使用必须由客户端解码的 JSON Web 令牌字符串进行响应。 Since the necessary library depends on crypto and stream , you won't be able to extract the JWT expiration time unless those dependencies are available.由于必要的库依赖于cryptostream ,除非这些依赖项可用,否则您将无法提取 JWT 到期时间。

In case anyone has trouble extrapolating from R. Richards' answer, you'll have to set to false any dependencies that are showing up in "can't resolve x" errors.如果有人无法从 R. Richards 的回答中推断出问题,您必须将出现在“无法解决 x”错误中的任何依赖项设置为 false。 For example, the critical part of my package.json is:例如,我的 package.json 的关键部分是:

    "browser": {
        "crypto": false,
        "stream": false
    }

I thought I would expand on what Tarique Ahmed wrote in his answer.我想我会扩展塔里克·艾哈迈德 (Tarique Ahmed) 在他的回答中所写的内容。

I was using an npm module that had the following line in the code:我使用的 npm 模块在代码中包含以下行:

const crypto = require('crypto');

I couldn't add:我无法添加:

"browser": {
  "crypto": false
}

to the package.json because the crypto package had to be part of the build.到 package.json 因为crypto包必须是构建的一部分。

It turns out that during the compilation process Angular seems to have decided to install the crypto-browserify package instead of crypto .事实证明,在编译过程中,Angular 似乎决定安装crypto-browserify包而不是crypto

Adding the following to the tsconfig.json file instructs the build to use the crypto-browserify library every time that crypto is required.将以下内容添加到tsconfig.json文件指示构建在每次需要crypto时使用crypto-browserify库。 As you can see, I had the same issue for the stream package.如您所见,我stream包有同样的问题。

"paths": {
  "crypto": [
    "node_modules/crypto-browserify"
  ],
  "stream": [
    "node_modules/stream-browserify"
  ]
}

After having the same issue with Angular 11 and crypto-js 4 (and manually setting the path in tsconfig.json), I found rolling back crypto-js to version 3.1.9-1 fixed the issue.在 Angular 11 和 crypto-js 4 遇到同样的问题(并在 tsconfig.json 中手动设置路径)后,我发现将 crypto-js 回滚到版本 3.1.9-1 解决了这个问题。 It seems a change made in version 4 caused the issue.似乎在第 4 版中所做的更改导致了该问题。

npm install crypto-js@3.1.9-1

Explained here in repo issues:在回购问题中解释如下:

GitHub issue GitHub 问题

If you upgraded to Webpack 5, you need to add this to your webpack config file :如果您升级到 Webpack 5,则需要将其添加到您的webpack 配置文件中

resolve: {
    fallback: { crypto: false },
},

aws-sign2 is a NodeJS package (and crypto is a NodeJS module), but it looks like you're dealing with a web application. aws-sign2是一个aws-sign2包(而crypto是一个 NodeJS 模块),但看起来您正在处理一个 Web 应用程序。 It makes sense that the crypto module is not available in that environment. crypto模块在该环境中不可用是有道理的。

Would it be possible to complete what you need to do server-side?是否有可能完成您需要在服务器端做的事情? Otherwise, you may need to look for another package.否则,您可能需要寻找另一个包。

After a deep a research i found that the solution is very simple: replace import * as CryptoJS from 'crypto-js';经过深入研究,我发现解决方案非常简单:将 import * 替换为 CryptoJS from 'crypto-js'; with declare var CryptoJS;使用声明 var CryptoJS;

For Laravel Inertia JS project, my solution was:对于 Laravel Inertia JS 项目,我的解决方案是:

1- Add dependencies to package.json 1- 向 package.json 添加依赖项

   "dependencies": {
        "crypto-browserify": "3.12.0",
        "crypto-random-string": "^3.3.0",
        "stream": "^0.0.2"
    }

2-In webpack.config.js: 2-在 webpack.config.js 中:

const path = require('path');

module.exports = {
    resolve: {
        alias: {
            '@': path.resolve('resources/js'),
        },
        fallback: {
            crypto: require.resolve('crypto-browserify'),
            stream: require.resolve('stream'),
        },
    },
};

3-Install, build and run: 3-安装、构建和运行:

npm install && npm run watch

I have resolved my issue using below steps:我已使用以下步骤解决了我的问题:

Add below to tsconfig.json to resolve crypto warning:将以下添加到tsconfig.json以解决加密警告:

"paths": {
      "crypto": [
        "node_modules/crypto-js"
      ]
    },

and add below to angular.json并将下面添加到angular.json

"options": {
"allowedCommonJsDependencies": [
              "crypto-js"
            ],
...
}

Add添加

npm install crypto-js

Or Add a specific version according to your project need或根据您的项目需要添加特定版本

npm install crypto-js@4.0.0

Also, run the above commands in Window "run as administrator" or in Linux use sudo此外,在 Window “以管理员身份运行”或在 Linux 中使用 sudo 运行上述命令

My Error我的错误

在此处输入图像描述

In my Case the import { get } from "express/lib/response" is the culprit, which is automatically added by vs-code.在我的案例中import { get } from "express/lib/response"是罪魁祸首,它是由 vs-code 自动添加的。 So, after removing it I solved my issue所以,删除它后,我解决了我的问题

在此处输入图像描述

Using direct import may not work with ES6 Enviornment..使用直接导入可能不适用于 ES6 环境。

This may help you.这可能对你有帮助。

$ npm i crypto-js@latest // For using latest version 4 $ npm i crypto-js@latest // 用于使用最新版本 4

import AES from 'crypto-js/aes';
import Utf8 from 'crypto-js/enc-utf8';
import { secretKey } from './environments/environment';

/** Encryption */
const data = {key: 'Test Value'};
const ciphertext = AES.encrypt(JSON.stringify(data), secretKey).toString();
console.log('Encrypted Data', ciphertext);

/** Decryption */
const bytes = AES.decrypt(ciphertext, secretKey);
const decryptedData = JSON.parse(bytes.toString(Utf8));
console.log('Decrypted Data', decryptedData);

https://github.com/brix/crypto-js/issues/168#issuecomment-785617218 https://github.com/brix/crypto-js/issues/168#issuecomment-785617218

Add the option allowedCommonJsDependencies with literal "crypto-js" in a array, this in file angular.json:在数组中添加带有文字“crypto-js”的 allowedCommonJsDependencies 选项,这在文件 angular.json 中:

"architect": 
        "build": {              
          "options": {               
            "allowedCommonJsDependencies": [
              "crypto-js"
            ]
          },
         }
 }

This will disable all warnings, tested in Angular 11.这将禁用在 Angular 11 中测试的所有警告。

My problem was that I was trying to build to node and web using the same code, but is not possible to built to web while importing a WebSocket dependency, ws in my case我的问题是我试图使用相同的代码构建到节点和 web,但是在导入 WebSocket 依赖项时无法构建到 web,在我的情况下是ws

So the solution is by using a wrapper:所以解决方案是使用包装器:

Install a wrapper, I will use isomorphic-ws because is made for ws安装一个包装器,我将使用isomorphic-ws因为是为ws制作的

npm i --save isomorphic-ws

Remove const WebSocket = require('ws')删除const WebSocket = require('ws')

Replace with:用。。。来代替:

const WebSocket = require('isomorphic-ws')

I had this problem in ReactJS with create-react-app(facebook)我在 ReactJS 中使用 create-react-app(facebook) 遇到了这个问题

Solution:解决方案:

  1. First install the necessary packages "crypto-browserify"首先安装必要的包“crypto-browserify”

  2. Modify webpack.config.js in reactjs with create-react-app this file is inside:使用 create-react-app 修改 reactjs 中的 webpack.config.js 这个文件在里面:

node_modules/react-scripts/config/webpack.config.js node_modules/react-scripts/config/webpack.config.js

  • Search module.exports and inside this function there is a return:搜索 module.exports 并在此函数中返回:
module.exports = function (webpackEnv) {
  ...
  return {
   ...
    resolve: {
      ...
      fallback: {
        // Here paste
        crypto: require.resolve("crypto-browserify"),

      }
    }
  }
}

Note: Is possible you need other packages how "stream-browserify" the steps are same.注意:您可能需要其他包,“stream-browserify”的步骤是一样的。 This solution works, but when the webpack project starts it shows warnings此解决方案有效,但当 webpack 项目启动时显示警告

Pd: I am not native speaker English, but I hope understand me. Pd:我的母语不是英语,但我希望能理解我。

I ended up going into我最终进入

node_modules/react-scripts/config/webpack.config.js node_modules/react-scripts/config/webpack.config.js

and adding:并添加:

fallback: {
        // Here paste
        crypto: require.resolve("crypto-browserify"),
        https: require.resolve("https-browserify"),
        http: require.resolve("stream-http"),
        url : require.resolve("url")
      }

And now my react app builds with errors but no dependency issues.现在我的反应应用程序构建错误但没有依赖问题。 Ill update this when I get it building.当我建立它时,我会更新它。

Alot of answers already but still none of them works.已经有很多答案,但仍然没有一个有效。 In my case I see warning message就我而言,我看到警告消息


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: { "crypto": require.resolve("crypto-browserify") }'         - install 'crypto-browserify' If you don't want to include a polyfill, you can use an empty module like this:         resolve.fallback: { "crypto": false }

comment from @stewii did helped me to resolved this. @stewii 的评论确实帮助我解决了这个问题。

There is now an ES modules version called "crypto-es".现在有一个名为“crypto-es”的 ES 模块版本。 It clears these warnings.它清除这些警告。 npmjs.com/package/crypto-es npmjs.com/package/crypto-es

After this I imported cryptoES在此之后我导入cryptoES

import CryptoES from 'crypto-es';

and remove the existing import of cryptoJs .并删除现有的cryptoJs导入。 Re-start the compile and Voila.. The warning message is gone.重新开始编译,瞧。警告信息消失了。

I tried a lot of the solutions above but the final thing that worked for me was downloading the crypto-es package and adding, "type":"module" to package.json.我尝试了上面的很多解决方案,但对我有用的最后一件事是下载密码 package 并将"type":"module"添加到 package.Z466DEEC76ECDF5FCA6D38571F6324D

https://www.npmjs.com/package/crypto-es https://www.npmjs.com/package/crypto-es

I was facing same issue, Just run node patch.js and it worked.我遇到了同样的问题,只需运行node patch.js就可以了。 The issue is, browser doesn't allow server files to be run on browser.问题是,浏览器不允许服务器文件在浏览器上运行。 In case you need some of these, You can use node patch.js .如果您需要其中一些,您可以使用node patch.js If you don't want to run any server file on browser, you can simply apply above mentioned solution by @R.Richards.如果您不想在浏览器上运行任何服务器文件,您可以简单地应用@R.Richards 的上述解决方案。 Might be helpful for someone..可能对某人有帮助..

When using #Laravel framework with Laravel Mix this is going to be more trick.当将#Laravel 框架与 Laravel 混合使用时,这将更具技巧。 I spend some hours on this NPM nightmare and found a solid solution.我在这个 NPM 噩梦上花了几个小时,找到了一个可靠的解决方案。

So, in your webpack.mix.js you find the 'comment'因此,在您的 webpack.mix.js 中,您会找到“评论”

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

Now just below that comment add the following lines;现在在该评论下方添加以下几行;

mix.webpackConfig(webpack => {
    return {
        plugins: [
            new webpack.LoaderOptionsPlugin({
                exports: {
                    resolve: {
                        fallback: {
                            crypto: require.resolve('crypto-browserify'),
                        }
                    }
                }
            })
        ]
    };
});

Now you can use Laravel Mix just like you would edit webpack.config.js;) Also;现在您可以像编辑 webpack.config.js 一样使用 Laravel Mix;)另外; In package.json remove:在 package.json 中删除:

--no-progress --hide-modules

These are no longer valid for WebPack >= 5. Enjoy!这些对 WebPack >= 5 不再有效。享受吧!

In my case, the solution described by R.Richards doesn't work.就我而言, R.Richards描述的解决方案不起作用。 However, following several threads along this issue, I finally understood where to insert the recommendation provided in the warning message and solved this warning.但是,随着这个问题的几个线程,我终于明白了在哪里插入警告消息中提供的建议并解决了这个警告。

WARNING in ./node_modules/bcryptjs/dist/bcrypt.js 64:13-45
Module not found: Error: Can't resolve 'crypto' in 'C:\PC\Documents\3 - Projet MAKAO\dev\RepoAlecol\node_modules\bcryptjs\dist'

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: { "crypto": require.resolve("crypto-browserify") }'
        - install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "crypto": false }**

Differently from many contributors, I didn't want to install crypto-browserify as I don't need it (*), and I chose to add the fallback { "crypto": false }.与许多贡献者不同,我不想安装 crypto-browserify,因为我不需要它 (*),我选择添加回退 { "crypto": false }。 However I didn't know where to add this fallback.但是我不知道在哪里添加这个后备。 After reading several threads, I found it was in the webpack.config.js file, which is located in the directory node_modules/react_scripts/config .在阅读了几个线程后,我发现它在 webpack.config.js 文件中,该文件位于目录 node_modules/react_scripts/config中。 Adding this fallback made the compilation succeed without any warning.添加此后备使编译成功而没有任何警告。

(*) PS: I once tried to add the following fallback { "crypto": require.resolve("crypto-browserify") }, but it led to generation of 7 errors, requiring other modules: (*) PS:我曾经尝试添加以下回退 { "crypto": require.resolve("crypto-browserify") },但它导致生成 7 个错误,需要其他模块:

    Failed to compile.

Module not found: Error: Can't resolve 'stream' in 'C:\PC\Documents\3 - Projet MAKAO\dev\RepoAlecol\node_modules\cipher-base'
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: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }
ERROR in ./node_modules/cipher-base/index.js 2:16-43
Module not found: Error: Can't resolve 'stream' in 'C:\PC\Documents\3 - Projet MAKAO\dev\RepoAlecol\node_modules\cipher-base'

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: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }

ERROR in ./node_modules/readable-stream/lib/_stream_readable.js 43:13-37
Module not found: Error: Can't resolve 'buffer' in 'C:\PC\Documents\3 - Projet MAKAO\dev\RepoAlecol\node_modules\readable-stream\lib'

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: { "buffer": require.resolve("buffer/") }'
        - install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "buffer": false }

ERROR in ./node_modules/readable-stream/lib/_stream_writable.js 65:13-37
Module not found: Error: Can't resolve 'buffer' in 'C:\PC\Documents\3 - Projet MAKAO\dev\RepoAlecol\node_modules\readable-stream\lib'

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: { "buffer": require.resolve("buffer/") }'
        - install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "buffer": false }

ERROR in ./node_modules/readable-stream/lib/internal/streams/buffer_list.js 63:15-32
Module not found: Error: Can't resolve 'buffer' in 'C:\PC\Documents\3 - Projet MAKAO\dev\RepoAlecol\node_modules\readable-stream\lib\internal\streams'

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: { "buffer": require.resolve("buffer/") }'
        - install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "buffer": false }

ERROR in ./node_modules/ripemd160/index.js 3:13-37
Module not found: Error: Can't resolve 'buffer' in 'C:\PC\Documents\3 - Projet MAKAO\dev\RepoAlecol\node_modules\ripemd160'

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: { "buffer": require.resolve("buffer/") }'
        - install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "buffer": false }

ERROR in ./node_modules/safe-buffer/index.js 3:13-30
Module not found: Error: Can't resolve 'buffer' in 'C:\PC\Documents\3 - Projet MAKAO\dev\RepoAlecol\node_modules\safe-buffer'

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: { "buffer": require.resolve("buffer/") }'
        - install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "buffer": false }

ERROR in ./node_modules/safer-buffer/safer.js 5:13-30
Module not found: Error: Can't resolve 'buffer' in 'C:\PC\Documents\3 - Projet MAKAO\dev\RepoAlecol\node_modules\safer-buffer'

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: { "buffer": require.resolve("buffer/") }'
        - install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "buffer": false }

webpack compiled with 7 errors

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM