我在使用纱线工作区和打字稿设置 React 项目时遇到问题。我的文件夹结构是:
-root
-package.json
-workspaces
-web
-common
Run Code Online (Sandbox Code Playgroud)
我的package.json文件是:
{
"name": "my-project-name",
"private": true,
"workspaces": [
"workspaces/web",
"workspaces/common"
],
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:当我web从common项目导入文件时,如果它是一个.js文件,它可以正常工作,但TypeError: Object(...) is not a function在使用.ts或.tsx文件时失败。
关于我可能缺少什么的任何想法?
我正在创建一个依赖于模块的应用程序。应用程序的文件结构是...
demo-app
|
|----package.json("workspaces": ["module-core/packages/*","src/packages/*" ])
|----src/
| |---packages/
| |---package.json ("workspaces": ["packages/*"])
| |---module-a
| |---package.json("name":"@app/module-a","private":true, "workspaces": ["packages/*"])
| |---module-b
| |---package.json("name":"@app/module-b","private":true, "workspaces": ["packages/*"])
|
|----module-core/
| |---package.json ("workspaces": ["packages/*"])
| |---packages/
| |---core-a
| |---package.json("name":"@app/core-a","private":true, "workspaces": ["packages/*"])
| |---core-b
| |---package.json("name":"@app/core-b","private":true, "workspaces": ["packages/*"])
Run Code Online (Sandbox Code Playgroud)
这里,
@app/module-a依赖于@app/core-a且@app/module-b依赖于@app/core-b。
我在演示应用程序中创建了一个工作区"workspaces": ["module-core/packages/*","src/packages/*"]。
运行时yarn install提示错误Couldn't find package "@app/module-a@^0.0.0" required by "@app/module-a@0.1.0" on the "npm" registry。
工作区管理中是否缺少它?
假设我在package.json文件中有以下依赖项部分:
"dependencies": {
"A": "1.0.0"
}
Run Code Online (Sandbox Code Playgroud)
同样,我们假设包 A 的当前版本是3.0.0. 但我的项目中需要版本1.0.0,A所以我在package.json.
鉴于此,我们假设B我的项目中需要有另一个依赖于A. 最新版本B也是3.0.0,但是不兼容"A": "1.0.0"。B与之兼容的正确版本"A": "1.0.0"是"B": "1.0.0".
问题是 -
如何检测与哪个版本的软件包
B兼容"A":"1.0.0"?有没有办法自动安装依赖
A并兼容的软件包版本"A": "1.0.0"?
我想部署一个应用程序,而不必捆绑文件夹中的所有node_modules。
因此,不要部署此文件夹:
拥有类似的东西:
中binary_dependencies应该只包含无法包含在app.js文件中的二进制文件。
原因是因为yarn install会在docker中创建一个大层(500MB)并且上传速度慢。我想缩小这个尺寸。
我在运行时yarn upgrade或install由于peerDependencies未满足而收到大量警告。
warning " > apollo-link-http@1.5.9" has unmet peer dependency "graphql@^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0".
warning " > babel-loader@8.0.4" has unmet peer dependency "@babel/core@^7.0.0".
Run Code Online (Sandbox Code Playgroud)
据我了解,列出的程序包需要依赖关系,而我项目中的另一个程序包具有依赖关系,我可以找到deps,但找不到任何有关如何将所述程序包定向到我所知道的子依赖关系的信息。 。
我怎样才能使纱线安静下来并显示这些小部件的位置?
它在本地运行良好。但是当我推送到 github 时,它无法通过 Travis。该包显示了我没有的,实际上在我的 package.json 中。我用的是 eslint,因为我关注的是eslint-prettier-airbnb
它使用节点 v8.16,
package.json
"eslint": "^5.3.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^4.3.0",
"eslint-loader": "^2.1.2",
"eslint-plugin-import": "^2.17.3",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-react": "^7.13.0",
Run Code Online (Sandbox Code Playgroud)
.eslintrc
{
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true,
"jquery": true,
"jest": true
},
"extends": ["eslint:recommended", "airbnb", "prettier"],
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"parser": "babel-eslint",
"plugins": ["react", "prettier"],
"rules": {
"prettier/prettier": ["error"],
}
}
Run Code Online (Sandbox Code Playgroud) 当我运行时yarn install,我的本机插件总是被重建。可以看出,即使没有更新任何内容,也node-gyp rebuild运行命令而不是node-gyp build。
caros@ubuntu:~/Developer/xviz-converter$ yarn install
yarn install v1.16.0
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
$ node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@10.16.0 | linux | x64
gyp info spawn /usr/bin/python2
....
Run Code Online (Sandbox Code Playgroud)
如何让纱线运行node-gyp build而不是node-gyp rebuild?完全重建非常耗时。
我正在尝试在我的计算机上安装 metronic,为此我需要安装 yarn。所以我运行了命令:
npm install --global yarn /Users/cbarrial/.npm-global/bin/yarn -> /Users/cbarrial/.npm-global/lib/node_modules/yarn/bin/yarn.js /Users/cbarrial/.npm- global/bin/yarnpkg -> /Users/cbarrial/.npm-global/lib/node_modules/yarn/bin/yarn.js + yarn@1.16.0 在 0.376 秒内更新了 1 个包
所以我想安装工作正常,但是如果我尝试使用 yarn 命令,我会得到这个:
纱线 --version -bash: 纱线: 找不到命令
我不知道问题出在哪里,我已经安装了最新的 npm 和 node.js 并且工作正常。
我正在尝试运行现有的世博会项目。我已经克隆了它并运行了纱线,然后博览会开始了。并收到此错误:
无法scheduler从/path-to-project/node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-prod.js以下位置解析模块:schedulerHaste 模块映射中不存在模块
这可能与https://github.com/facebook/react-native/issues/4968有关
尝试通过以下方式解决:
watchman watch-del-all.node_modules文件夹:rm -rf node_modules && npm install。rm -rf /tmp/metro-bundler-cache-*或npm start -- --reset-cache。rm -rf /tmp/haste-map-react-native-packager-*。线索:尝试运行iOS模拟器时,budling卡在%99
Building JavaScript bundle [================================= ] 99%
Run Code Online (Sandbox Code Playgroud)
在那之后:
Failed building JavaScript bundle.
Run Code Online (Sandbox Code Playgroud) 要运行本地服务器进行开发,我通常使用yarn run dev.
但它似乎yarn dev提供了相同的功能。这个命令只是一个简短的别名吗yarn run dev?
yarn dev我在文档中找不到信息。
yarnpkg ×10
node.js ×4
npm ×4
javascript ×2
reactjs ×2
bash ×1
docker ×1
eslint ×1
expo ×1
installation ×1
node-gyp ×1
react-native ×1
rebuild ×1
travis-ci ×1
ts-loader ×1
typescript ×1
web ×1
webpack ×1