问题描述:
Angular项目使用ng build --prod打包时出现如下提示信息
DeprecationWarning: Use of deprecated folder mapping “./” in the “exports” field module resolution of the package at D:…\package.json.
Update this package.json to use a subpath pattern like “./*”.
WARNING in ./node_modules/crypto-js/core.js
Module not found: Error: Can’t resolve ‘crypto’ in ‘D:…\node_modules\crypto-js’
resolve ‘crypto’ in ‘D:…\node_modules\crypto-js’
Parsed request is a module
using description file: D:\ …\node_modules\crypto-js\package.json (relative path: .)
Field ‘browser’ doesn’t contain a valid alias configuration
…
解决方案:
根据提示找到对应的package.json文件
更新package.json的子路径模式,如"./*"。
在package.json中加入
"browser": {
"crypto": false
}