您只想使用 webpack5 分别构建 Express 和 gql 服务器相关的文件。
\n但是,构建时出现错误。
\n\n主错误
\n
\n找不到模块:错误:无法解析'/Users/leedonghee/Dropbox/Project/observer/Homepage/v2/server 中的'./src'
我的文件在任何地方都不使用 ./src 。
\nserver(root)\n\xe2\x94\x9c\xe2\x94\x80 dist\n\xe2\x94\x9c\xe2\x94\x80 model(mongoose & gql)\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80 schema.js\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80 main-sliders\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80 model.js\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80 resolver.js\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80 schema.graphql\n\xe2\x94\x9c\xe2\x94\x80 node_modules\n\xe2\x94\x9c\xe2\x94\x80 index.js\n\xe2\x94\x9c\xe2\x94\x80 webpack.config.js\n\xe2\x94\x9c\xe2\x94\x80 .babelrc\n\xe2\x94\x9c\xe2\x94\x80 .env\n\xe2\x94\x9c\xe2\x94\x80 package.json\n\xe2\x94\x9c\xe2\x94\x80 package-lock.json\n\xe2\x94\x94\xe2\x94\x80 ...\nRun Code Online (Sandbox Code Playgroud)\n{\n "name": "server",\n "version": "1.0.0",\n "description": "",\n "private": true,\n "scripts": {\n "dev:server": "NODE_ENV=development nodemon --exec babel-node index.js",\n "build": "webpack --mode production --progress",\n "start:server": "NODE_ENV=production node ./build/index.js"\n },\n "keywords": [],\n "author": "",\n …Run Code Online (Sandbox Code Playgroud) 使用webpack打包时出现以下错误。
我按照错误描述的方法设置了,但是不知道问题出在哪里。
共有42个重复错误。
ERROR in ./node_modules/apollo-env/lib/utils/createHash.js 6:15-39
Module not found: Error: Can't resolve 'crypto' in '/Users/pj/v2/server/node_modules/apollo-env/lib/utils'
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 …Run Code Online (Sandbox Code Playgroud)