我学习yalc并做它说的完全正确的事情,但是当我更改了yalc publish
上的库代码时,我在我的应用程序中看不到代码的变化。
图书馆是通知栈
步骤:
yalc link notistack
中运行yalc link notistack
然后,当我更改通知堆栈代码并运行yalc push
时,什么都不会发生,但文档说我应该在我的应用程序中得到代码更改?
我甚至重新启动App并执行yalc update notistack
,但是通知堆栈代码更改是不可见的。
奇怪的是,在我的应用程序VSCode node_modules中,我看到了notistack
代码的变化。这就像yalc push
正在向应用程序传播通知堆栈更改,但是应用程序没有使用它们。
更奇怪的是,当我重新启动VSCode并启动App进行调试时,仍然使用旧的通知堆栈代码。
我测试删除yalc remove notistack
并重新启动膝上型计算机,然后再执行yalc add notistack
。然后我又看到了旧代码。
我尝试在Chrome浏览器做硬复位空现金,但没有运气,使这个工作。
当我去yalc商店看看: C:\Users\user\AppData\Local\Yalc\packages\notistack\1.0.10\src:
我看到最新的密码了。
在Chrome检查控制台中,我看到了旧代码,但在检查器源代码下,有正确的代码。太让人困惑了。我也不能在检查器或VSCode中设置通知堆栈中的断点。就像JavaScript文件被错位了一样。
在Edge和Chrome中都会发生这种情况。
两天后我要做什么才能继续工作,我必须删除Yalc存储文件夹,C:\Users\user\AppData\Local\Yalc\packages\noti...............。应用程序项目删除包中删除的yalc.lock -lock.json和node_modules
然后重新发布和添加通知堆栈。这很费时,但很管用。
如何在Yalc中显示代码更改?
通知堆栈的package.json
{
"name": "notistack",
"version": "1.0.10",
"description": "Highly customizable notification snackbars (toasts) that can be stacked on top of each other",
"main": "src/index.js",
"module": "dist/notistack.esm.js",
"types": "src/index.d.ts",
"license": "MIT",
"author": {
"name": "Hossein Dehnokhalaji",
"email": "hossein.dehnavi98@yahoo.com",
"url": "https://github.com/iamhosseindhv/notistack"
},
"homepage": "https://www.iamhosseindhv.com/notistack",
"repository": {
"url": "git+https://github.com/iamhosseindhv/notistack.git",
"type": "git"
},
"scripts": {
"build": "tsdx build --transpileOnly --entry ./src/index.js",
"prebuild": "npm run docs",
"prepublishOnly": "npm run build",
"docs": "rimraf typedoc.json && typedoc --tsconfig",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"peerDependencies": {
"@material-ui/core": "^4.0.0",
"react": "^16.8.0 || ^17.0.0",
"react-dom": "^16.8.0 || ^17.0.0"
},
"dependencies": {
"clsx": "^1.1.0",
"hoist-non-react-statics": "^3.3.0"
},
"bugs": {
"url": "https://github.com/iamhosseindhv/notistack/issues"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/notistack"
},
"contributors": [
"Hossein Dehnokhalaji (https://www.iamhosseindhv.com/)"
],
"keywords": [
"notistack",
"enqueueSnackbar",
"snackbarprovider",
"useSnackbar",
"multiple",
"react",
"javascript",
"material-ui",
"toast",
"redux",
"snackbar",
"stacked",
"notification",
"material design",
"hossein",
"dehnokhalaji",
"iamhosseindhv"
],
"yalcSig": "073ef039ed1e473029c88b6ad9af16d9"
}
更新
添加应用程序package.json
{
"name": "greta-thunberg-fff",
"version": "1.2.9",
"private": true,
"homepage": "https://greta.portplays.com",
"main": "index.js",
"module": "dist/index.js",
"files": [
"dist",
"README.md"
],
"dependencies": {
"@material-ui/core": "^4.11.2",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.57",
"@material-ui/styles": "^4.11.2",
"axios": "^0.19.2",
"bootstrap": "^4.5.2",
"change-case": "^4.1.2",
"classnames": "^2.3.1",
"clean-tag": "^3.1.1",
"clsx": "^1.1.1",
"comma-separated-values": "^3.6.4",
"crypto-js": "^4.0.0",
"date-fns": "^2.23.0",
"faker": "^5.5.3",
"firebase": "^7.23.0",
"formik": "^2.2.5",
"framer-motion": "^2.9.5",
"gsap": "^3.5.1",
"history": "^5.0.0",
"i": "^0.3.6",
"lodash": "^4.17.19",
"lodash.debounce": "^4.0.8",
"mammoth": "^1.4.11",
"material-table": "^1.69.2",
"moment": "^2.27.0",
"my-notistack-fork": "file:.yalc/my-notistack-fork",
"normalize-wheel": "^1.0.1",
"npm": "^7.11.2",
"pdfjs-dist": "^1.8.357",
"preval.macro": "^5.0.0",
"prop-types": "^15.7.2",
"react": "^17.0.2",
"react-activity": "^1.2.2",
"react-bootstrap": "^1.3.0",
"react-chartjs-2": "^2.11.1",
"react-data-grid": "^6.1.0",
"react-detect-offline": "^2.4.0",
"react-dom": "^17.0.2",
"react-dropzone": "^11.3.4",
"react-helmet": "^6.1.0",
"react-motion": "^0.5.2",
"react-perfect-scrollbar": "^1.5.8",
"react-redux": "^7.2.5",
"react-resize-detector": "^5.0.7",
"react-router": "^6.0.0-beta.4",
"react-router-dom": "^6.0.0-beta.4",
"react-scripts": "^3.4.0",
"react-slick": "^0.27.3",
"react-spring": "^8.0.27",
"react-transition-group": "^4.4.1",
"react-visibility-sensor": "^5.1.1",
"rebass": "^4.0.7",
"recompose": "^0.30.0",
"redux": "^4.1.1",
"redux-logger": "^3.0.6",
"redux-saga": "^1.1.3",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"sass": "^1.41.1",
"simplebar-react": "^2.3.5",
"slick-carousel": "^1.8.1",
"styled-components": "^5.1.1",
"styled-system": "^5.1.5",
"three": "^0.85.2",
"typescript": "^3.9.7",
"uuid": "^8.3.1",
"xlsx": "^0.10.1",
"yup": "^0.32.1"
},
"scripts": {
"start": "set PORT=6545&& react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -b master -d build"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.1.1",
"@typescript-eslint/parser": "^4.1.1",
"axios": "^0.19.2",
"babel-eslint": "^10.1.0",
"clean-tag": "^3.1.1",
"eslint": "^6.6.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.2",
"gh-pages": "^2.0.1",
"prettier": "^2.1.1",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-scripts": "^3.4.3",
"rebass": "^4.0.7",
"styled-system": "^5.1.5"
}
}
发布于 2021-10-24 07:00:20
我使用yalc add notistack
复制了您的设置,并注意到yalc push
没有编译这个包。当我添加标记--scripts
(如文档中所描述的)时,它起了作用:
默认情况下,
scripts
选项是假的,因此它不会运行预/后脚本(可能会通过传递--scripts
标志来更改这一点)。
您还可以运行yalc publish
,然后运行yalc push
或yalc publish --push
。
为了使更改在应用程序中生效,我不得不再次运行npm start
。
这是通知堆栈依赖项在package.json中的外观。
"notistack": "file:.yalc/notistack",
更新
正如您所指出的,我还尝试通过在my-notistack-fork
中更改名称将包重命名为package.json
。
{
"name": "my-notistack-fork",
"version": "2.0.2",
"description": "Highly customizable notification snackbars (toasts) that can be stacked on top of each other",
然后用yalc remove notistack
删除我的应用程序中的通知堆栈依赖项,然后使用新的名称yalc add my-notistack-fork
再次添加它。之后,我对库代码进行了修改,并运行了yalc publish --push
,在再次运行应用程序时可以看到它们的反映。依赖性如下所示
"my-notistack-fork": "file:.yalc/my-notistack-fork",
有趣的是,对于我来说,在应用程序node_modules中,lib目录已经编译了文件,而屏幕快照中的错误有一个src
dir,它给人的印象是它是未编译的。
发布于 2021-10-24 17:43:11
如果我正确理解了一切,我就会发现两个问题:
首先,我必须承认我不知道yalc
,但是在快速查看它之后,我想说它似乎和npm
一样有效;我将用npm
提供我的答案,我让您使用yalc
来修改我的答案;但是我非常肯定,这只是运行yalc
命令而不是使用相同参数的npm
命令的问题。
1.分叉npm软件包
如果我正确地理解了你不是notistack
的作者,你有你自己的叉子,但我仍然不知道它的名字。
会不会是你把notistack
分叉了却没有改名呢?
因此,当我们想要分发一个包时,我们需要给它一个新的名称,比如my-notistak-fork
;package.json
文件看起来应该如下所示:
{
"name": "my-notistack-fork",
"version": "new version progression numbers",
"license": "MIT",
"author": {
... describe yourself
},
"homepage": "a new homepage, if you have one",
"repository": {
"url": "URL of your fork"
},
"bugs": {
"url": "URL of issues in your fork"
},
"funding": {
... if you have one, describe it
},
"contributors": [
... who contribute to your fork
],
...
}
我只写了需要修改的字段,其他的可以不动(但这取决于您更改包的程度,无论如何,这是另一个主题)。
使用npm publish
命令发布它。
现在您已经发布了my-notistack-fork
,它是notistack
的一个克隆(在版本中是分叉的)。
2.同时处理两个包
对于npm
来说,这是一件微不足道的事情,而且工作得很好。
my-notistack-fork
存储库的根目录中,发出npm link
命令。npm add my-notistack-fork
npm link my-notistack-fork
npm install
就这样。现在,更改两个存储库中的每个存储库中的文件应该立即反映您的调试/开发环境。
在这样做之前清除本地应用服务器存储库的根目录可能是个好主意。我是说:
node_modules
目录package-lock.json
和/或yalc
文件)notistack
文件中删除对package.json
的任何引用https://stackoverflow.com/questions/69575534
复制相似问题