我正在通过 React 运行一个项目,“@codingame/monaco-languageclient”:“^0.17.3”,“monaco-editor”:“^0.31.1”和“react-monaco-editor”:“^0.35。 0”。编译给出了以下错误:
Failed to compile.
./node_modules/vscode-languageclient/lib/common/client.js
Module not found: Can't resolve 'vscode' in '/Users/SoftTimur/10Studio/frontend/node_modules/vscode-languageclient/lib/common'
我找到了这个线程,并且确实'vscode': require.resolve('monaco-languageclient/lib/vscode-compatibility')
有他们webpack.config.js
的例子。
然后我添加'vscode': require.resolve('@codingame/monaco-languageclient/lib/vscode-compatibility'),
到alias
. node_modules/react-scripts/config/webpack.config.js
它确实解决了错误。
但是,问题是如果我重新安装项目,我必须再次添加。有谁知道是否有自动注入'vscode': require.resolve('@codingame/monaco-languageclient/lib/vscode-compatibility'),
的alias
方式node_modules/react-scripts/config/webpack.config.js
?
PS:我已经在使用 react-app-rewired 了。