同步 node_modules 时撤消 npm link,react & react-dom
Undo npm link when syncing node_modules, react & react-dom
我发现此修复程序解决了我在开发的包中尝试使用挂钩并在尝试使用 React 的多个实例时遇到错误的问题。这对我有用,但我想知道当我准备好从 NPM 测试我的包时如何“撤消”所有这些。当我只使用 'npm link' 时,我会使用 'npm unlink'。我如何在此处应用它并使我的应用程序恢复到其原始状态,尤其是在应用程序内的第一部分,以及 pushd 和 popd。
I was using npm link between an app and a module I was actively working on,
and I had to fix it by linking the app's react and react-dom to the module,
then linking the module to the app:
in app:
pushd node_modules/react && npm link; popd
pushd node_modules/react-dom && npm link; popd
in module:
npm link # this creates a global link for module.
npm link react && npm link react-dom # link app's react and react-dom, so they're in sync.
in app:
npm link [module-name] # this replace the module lib in node_modules with a link to the module's local copy.
运行 在您的应用中添加 npm install
,这将重新安装您链接的模块。
您真的不需要担心您在 react
和 react-dom
上创建的链接。这不会对您的应用产生任何影响。
如果实在嫌麻烦,可以到以下目录手动删除:
<your_home_dir>/nvm/nodejs/<you_node_version>/lib/node_modules/react -> <your_app's_react_dir>
<your_home_dir>/nvm/nodejs/<you_node_version>/lib/node_modules/react-dom -> <your_app's_react-dom_dir>
如果您不使用它们,它们只是一些无用的链接。
我发现此修复程序解决了我在开发的包中尝试使用挂钩并在尝试使用 React 的多个实例时遇到错误的问题。这对我有用,但我想知道当我准备好从 NPM 测试我的包时如何“撤消”所有这些。当我只使用 'npm link' 时,我会使用 'npm unlink'。我如何在此处应用它并使我的应用程序恢复到其原始状态,尤其是在应用程序内的第一部分,以及 pushd 和 popd。
I was using npm link between an app and a module I was actively working on,
and I had to fix it by linking the app's react and react-dom to the module,
then linking the module to the app:
in app:
pushd node_modules/react && npm link; popd
pushd node_modules/react-dom && npm link; popd
in module:
npm link # this creates a global link for module.
npm link react && npm link react-dom # link app's react and react-dom, so they're in sync.
in app:
npm link [module-name] # this replace the module lib in node_modules with a link to the module's local copy.
运行 在您的应用中添加 npm install
,这将重新安装您链接的模块。
您真的不需要担心您在 react
和 react-dom
上创建的链接。这不会对您的应用产生任何影响。
如果实在嫌麻烦,可以到以下目录手动删除:
<your_home_dir>/nvm/nodejs/<you_node_version>/lib/node_modules/react -> <your_app's_react_dir>
<your_home_dir>/nvm/nodejs/<you_node_version>/lib/node_modules/react-dom -> <your_app's_react-dom_dir>
如果您不使用它们,它们只是一些无用的链接。