未从 git url 依赖项中找到模块
Module Not Found from git url dependency
我已经 fork react-flexbox-grid 来添加对隐藏列的支持(这是我第一次贡献)但是我无法在我的项目中包含这个包。
根据 Docs: Git Urls as Dependencies,我将以下内容放入 package.json:
"react-flexbox-grid": "falieson/react-flexbox-grid#hidden-columns",
在 运行 npm i 之后,我看到 npm 获取并且安装包没有错误。
├── react-dom@15.4.1
├── react-flexbox-grid@0.10.2 (git://github.com/falieson/react-flexbox-grid.git#f8e9e9053430b619f4c7fd79b90ccd4f44d6a05c)
├── react-fontawesome@1.5.0
但是当我启动服务器时meteor:webpack抱怨:
ERROR in ./imports/ui/Home/index.jsx
Module not found: Error: Cannot resolve module 'react-flexbox-grid' in /Users/falieson/Code/planetx-boilerplate/imports/ui/Home
我没有在 index.jsx
上进行任何更改
import {Grid, Row, Col} from 'react-flexbox-grid';
这是我的 meteor webpack config:
{
"css": {
"module": true
},
"module": {
"loaders": [
{
"test": "/\.css$/",
"loader": "style!css?modules",
"include": "/flexboxgrid/"
}
]
}
}
不应该是这样吗:
"react-flexbox-grid": "falieson/react-flexbox-grid#hidden-columns",
在 package.json 中没有 git
?
通常我会说它可能是一个你可以安装的私有模块,因为你有这样做的权限,但在其他环境中它不能被访问,因为 GitHub 为私有 repos 提供 404 如果您无权访问它们。或者你可能没有一个名为 "hidden-columns" 的分支或抹布,但在这里你似乎有那个分支并且模块是 public 所以这不是问题。
问题是这个 repo 需要构建,package.json 指的是 ./lib/index.js 文件,但它不存在于 repo 中(只有 src 文件夹)。
您可以在本地构建它:
npm run compile
并强制添加 ./lib 文件夹并将其推送到您的 git 存储库。
- 确保您编译的文件在提交中。
- 确保 git ignore 更新为不忽略你编译的文件。
npm rm -rf ./node_modules/xxxx
如果模块已经安装
npm install --save-dev https://gitlab.com/m_farhan/xxxxx.git#master
- 确保在将代码推送到存储库之前构建代码。
- npm xxxxx 更新你的项目。
我已经 fork react-flexbox-grid 来添加对隐藏列的支持(这是我第一次贡献)但是我无法在我的项目中包含这个包。
根据 Docs: Git Urls as Dependencies,我将以下内容放入 package.json:
"react-flexbox-grid": "falieson/react-flexbox-grid#hidden-columns",
在 运行 npm i 之后,我看到 npm 获取并且安装包没有错误。
├── react-dom@15.4.1 ├── react-flexbox-grid@0.10.2 (git://github.com/falieson/react-flexbox-grid.git#f8e9e9053430b619f4c7fd79b90ccd4f44d6a05c) ├── react-fontawesome@1.5.0
但是当我启动服务器时meteor:webpack抱怨:
ERROR in ./imports/ui/Home/index.jsx Module not found: Error: Cannot resolve module 'react-flexbox-grid' in /Users/falieson/Code/planetx-boilerplate/imports/ui/Home
我没有在 index.jsx
上进行任何更改import {Grid, Row, Col} from 'react-flexbox-grid';
这是我的 meteor webpack config:
{
"css": {
"module": true
},
"module": {
"loaders": [
{
"test": "/\.css$/",
"loader": "style!css?modules",
"include": "/flexboxgrid/"
}
]
}
}
不应该是这样吗:
"react-flexbox-grid": "falieson/react-flexbox-grid#hidden-columns",
在 package.json 中没有 git
?
通常我会说它可能是一个你可以安装的私有模块,因为你有这样做的权限,但在其他环境中它不能被访问,因为 GitHub 为私有 repos 提供 404 如果您无权访问它们。或者你可能没有一个名为 "hidden-columns" 的分支或抹布,但在这里你似乎有那个分支并且模块是 public 所以这不是问题。
问题是这个 repo 需要构建,package.json 指的是 ./lib/index.js 文件,但它不存在于 repo 中(只有 src 文件夹)。
您可以在本地构建它:
npm run compile
并强制添加 ./lib 文件夹并将其推送到您的 git 存储库。
- 确保您编译的文件在提交中。
- 确保 git ignore 更新为不忽略你编译的文件。
npm rm -rf ./node_modules/xxxx
如果模块已经安装npm install --save-dev https://gitlab.com/m_farhan/xxxxx.git#master
- 确保在将代码推送到存储库之前构建代码。
- npm xxxxx 更新你的项目。