【发布时间】:2021-04-12 12:11:22
【问题描述】:
我正在尝试在我的 react 项目中安装 react-cookie 依赖项。 React 项目在没有互联网连接的独立离线网络上运行。依赖项被打包到一个 tarball 文件中并上传到服务器上。然后我跑
npm install react-cookie-4.0.3.tgz
但我得到以下错误
ERR! network request to https://registry.npmjs.org/@emotion%2fcore failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
我该如何解决这个问题?
【问题讨论】:
-
会不会是
react-cookie有一些依赖,npm 也在尝试下载? -
但是,您应该将包复制到项目 node_modules 文件夹(包括所有依赖项)并在根文件夹中点击
npm install。应该做的伎俩(可能重复:stackoverflow.com/questions/43064107/…) -
您如何构建和打包您的应用程序?您不需要为已部署的应用程序执行 npm install。
-
这能回答你的问题吗? How to install npm package while offline?