尝试使用新的 DSE 初始化全新的“JAMStack + Netlify + Astra + Cassandra”。
$ netlify dev
◈ Netlify Dev ◈
◈ Overriding command with setting derived from netlify.toml [dev] block: yarn webpack-dev-server
◈ Functions server is listening on 42051
◈ Starting Netlify Dev with #custom
$ /workspace/todo-astra-jamstack-netlify/node_modules/.bin/webpack-dev-server
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'webpack-cli/bin/config-yargs'
Require stack:
/workspace/todo-astra-jamstack-netlify/node_modules/webpack-dev-server/bin/webpack-dev-server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object. (/workspace/todo-astra-jamstack-netlify/node_modules/webpack-dev-server/bin/webpack-dev-server.js:65:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/workspace/todo-astra-jamstack-netlify/node_modules/webpack-dev-server/bin/webpack-dev-server.js'
]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
◈ "yarn webpack-dev-server" exited with code 1. Shutting down Netlify Dev server
error Command failed with exit code 1.
I tried the same locally npm -v 7.6.3 throws same error.
将 package.json 更改为
"webpack": "^5.0.0-rc.3",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0"
使用旧参数导入不会引发错误:
npm install --legacy-peer-deps
但有警告:
WARNING in ./node_modules/node-uuid/uuid.js 59:18-47
Module not found: Error: Can't resolve 'crypto' in 'D:\Projects\DSE\todo-astra-jamstack-netlify\node_modules\node-uuid'
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 }
并且无法将任何数据保存到 Astra 表中。
重现步骤:创建新的 DataStax Astra db/keyspace 如下所述启动 Netlify:https ://github.com/DataStax-Examples/todo-astra-jamstack-netlify#readme 查看错误预期行为 Application React To-Do saves data和待办事项列表。