Kil*_*ims 5 reactjs create-react-app babel-loader storybook react-app-rewired
create-react-app version
\nreact: v17.0.1\nreact-scripts: v4.0.1 \nRun Code Online (Sandbox Code Playgroud)\n故事书版本
\n@storybook/react: v6.1.6\n@storybook/addon-docs: v6.1.6\n@storybook/core: v6.1.6\nRun Code Online (Sandbox Code Playgroud)\n我可以运行yarn start反应应用程序并且可以运行start-storybook -p 9009 -s public to start storybook.
当涉及到构建 React 应用程序时,就会出现问题。往下看。
\nreact-app-rewired start.There might be a problem with the project dependency tree.\nIt is likely not a bug in Create React App, but something you need to fix locally.\n\nThe react-scripts package provided by Create React App requires a dependency:\n\n "babel-loader": "8.1.0"\n\nDon\'t try to install it manually: your package manager does it automatically.\nHowever, a different version of babel-loader was detected higher up in the tree:\n\n /Users/yejinlei/Documents/playground/personal/react-temp/node_modules/babel-loader (version: 8.2.1) \n\nManually installing incompatible versions is known to cause hard-to-debug issues.\n\nIf you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.\nThat will permanently disable this message but you might encounter other issues.\n\nTo fix the dependency tree, try following the steps below in the exact order:\n\n 1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.\n 2. Delete node_modules in your project folder.\n 3. Remove "babel-loader" from dependencies and/or devDependencies in the package.json file in your project folder.\n 4. Run npm install or yarn, depending on the package manager you use.\n\nIn most cases, this should be enough to fix the problem.\nIf this has not helped, there are a few other things you can try:\n\n 5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.\n This may help because npm has known issues with package hoisting which may get resolved in future versions.\n\n 6. Check if /Users/yejinlei/Documents/playground/personal/react-temp/node_modules/babel-loader is outside your project directory.\n For example, you might have accidentally installed something in your home folder.\n\n 7. Try running npm ls babel-loader in your project folder.\n This will tell you which other package (apart from the expected react-scripts) installed babel-loader.\n\nIf nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.\nThat would permanently disable this preflight check in case you want to proceed anyway.\n\nP.S. We know this message is long but please read the steps above :-) We hope you find them helpful!\nRun Code Online (Sandbox Code Playgroud)\n我跑npm ls babel-loader and see below show
react-temp@0.1.0 /Users/yejinlei/Documents/playground/personal/react-temp\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/addon-docs@6.1.6\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\xac @storybook/core@6.1.6\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 babel-loader@8.2.1 deduped\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 babel-loader@8.2.1 \nRun Code Online (Sandbox Code Playgroud)\nyarn add babel-loader@8.1.0. when it done i get below :react-temp@0.1.0 /Users/yejinlei/Documents/playground/personal/react-temp\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/addon-docs@6.1.6\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\xac @storybook/core@6.1.6\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 babel-loader@8.2.1 \n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 babel-loader@8.1.0 \nRun Code Online (Sandbox Code Playgroud)\nyarn run build,它实际运行react-app-rewired build并得到以下错误playground/personal/react-temp/node_modules/react-scripts/scripts/build.js:19\n throw err;\n ^\n\nTypeError: aGeneratedCode.split is not a function\n at Function.SourceNode_fromStringWithSourceMap [as fromStringWithSourceMap] (playground/personal/react-temp/node_modules/source-map/lib/source-node.js:64:41)\nRun Code Online (Sandbox Code Playgroud)\n无法建造
\n所以我的目标是代码node_modules/source-map/lib/source-node.js
并查看错误代码:
\n/node_modules/source-map/lib/source-node.js\n\n64 var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);\n\nRun Code Online (Sandbox Code Playgroud)\n我运行并分析代码。aGenerateCode 将是“obejct”,所以我更改代码如下。
\n var remainingLines = typeof(aGeneratedCode) === "string" ? aGeneratedCode.split(REGEX_NEWLINE) : [];\nRun Code Online (Sandbox Code Playgroud)\n然后我现在可以运行 cra 应用程序和故事书的构建/启动。
\n但为什么以及如何永久修复它?
\n我能够使用“决议”属性来解决这个问题(https://classic.yarnpkg.com/en/docs/package-json/#toc-resolutions)
"resolutions": {
"babel-loader": "8.1.0"
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1698 次 |
| 最近记录: |