pubspec.lock 的第 3 行第 1 列出错:只需要一个文档
Posted
技术标签:
【中文标题】pubspec.lock 的第 3 行第 1 列出错:只需要一个文档【英文标题】:Error on line 3, column 1 of pubspec.lock: Only expected one document 【发布时间】:2021-10-19 19:58:39 【问题描述】:尝试启动 Flutter 项目时出现错误。
[modules/common_library] flutter pub get
Running "flutter pub get" in common_library...
Error on line 3, column 1 of pubspec.lock: Only expected one document.
╷
3 │ ┌ packages:
4 │ │ args:
5 │ │ dependency: transitive
6 │ │ description:
7 │ │ name: args
8 │ │ url: "https://pub.dartlang.org"
9 │ │ source: hosted
10 │ │ version: "2.1.0"
11 │ │ asn1lib:
12 │ │ dependency: transitive
13 │ │ description:
14 │ │ name: asn1lib
15 │ │ url: "https://pub.dartlang.org"
16 │ │ source: hosted
17 │ │ version: "1.0.0"
18 │ │ async:
19 │ │ dependency: transitive
20 │ │ description:
21 │ │ name: async
22 │ │ url: "https://pub.dartlang.org"
23 │ │ source: hosted
24 │ │ version: "2.6.1"
25 │ │ characters:
26 │ │ dependency: transitive
27 │ │ description:
28 │ │ name: characters
29 │ │ url: "https://pub.dartlang.org"
30 │ │ source: hosted
31 │ │ version: "1.1.0"
32 │ │ charcode:
33 │ │ dependency: transitive
34 │ │ description:
35 │ │ name: charcode
36 │ │ url: "https://pub.dartlang.org"
37 │ │ source: hosted
38 │ │ version: "1.2.0"
39 │ │ clock:
40 │ │ dependency: transitive
41 │ │ description:
42 │ │ name: clock
43 │ │ url: "https://pub.dartlang.org"
44 │ │ source: hosted
45 │ │ version: "1.1.0"
46 │ │ collection:
47 │ │ dependency: transitive
48 │ │ description:
49 │ │ name: collection
50 │ │ url: "https://pub.dartlang.org"
51 │ │ source: hosted
52 │ │ version: "1.15.0"
53 │ │ crypto:
54 │ │ dependency: transitive
55 │ │ description:
56 │ │ name: crypto
57 │ │ url: "https://pub.dartlang.org"
58 │ │ source: hosted
59 │ │ version: "3.0.1"
60 │ │ cupertino_icons:
61 │ │ dependency: transitive
62 │ │ description:
63 │ │ name: cupertino_icons
64 │ │ url: "https://pub.dartlang.org"
65 │ │ source: hosted
66 │ │ version: "1.0.3"
67 │ │ dio:
68 │ │ dependency: "direct main"
69 │ │ description:
70 │ │ name: dio
71 │ │ url: "https://pub.dartlang.org"
72 │ │ source: hosted
73 │ │ version: "4.0.0"
74 │ │ encrypt:
75 │ │ dependency: "direct main"
76 │ │ description:
77 │ │ name: encrypt
78 │ │ url: "https://pub.dartlang.org"
79 │ │ source: hosted
80 │ │ version: "5.0.0"
81 │ │ event_bus:
82 │ │ dependency: "direct main"
83 │ │ description:
84 │ │ name: event_bus
85 │ │ url: "https://pub.dartlang.org"
86 │ │ source: hosted
87 │ │ version: "2.0.0"
88 │ │ extended_image:
89 │ │ dependency: "direct main"
90 │ │ description:
91 │ │ name: extended_image
92 │ │ url: "https://pub.dartlang.org"
93 │ │ source: hosted
94 │ │ version: "4.1.0"
95 │ │ extended_image_library:
96 │ │ dependency: transitive
97 │ │ description:
98 │ │ name: extended_image_library
99 │ │ url: "https://pub.dartlang.org"
100 │ │ source: hosted
101 │ │ version: "3.1.0"
102 │ │ ffi:
103 │ │ dependency: transitive
104 │ │ description:
105 │ │ name: ffi
106 │ │ url: "https://pub.dartlang.org"
107 │ │ source: hosted
108 │ │ version: "1.0.0"
109 │ │ file:
110 │ │ dependency: transitive
111 │ │ description:
112 │ │ name: file
113 │ │ url: "https://pub.dartlang.org"
114 │ │ source: hosted
115 │ │ version: "6.1.0"
116 │ │ flutter:
117 │ │ dependency: "direct main"
118 │ │ description: flutter
119 │ │ source: sdk
120 │ │ version: "0.0.0"
121 │ │ flutter_iconpicker:
122 │ │ dependency: "direct main"
123 │ │ description:
124 │ │ name: flutter_iconpicker
125 │ │ url: "https://pub.dartlang.org"
126 │ │ source: hosted
127 │ │ version: "3.0.1+2"
128 │ │ font_awesome_flutter:
129 │ │ dependency: transitive
130 │ │ description:
131 │ │ name: font_awesome_flutter
132 │ │ url: "https://pub.dartlang.org"
133 │ │ source: hosted
134 │ │ version: "9.0.0"
135 │ │ google_fonts:
136 │ │ dependency: "direct main"
137 │ │ description:
138 │ │ name: google_fonts
139 │ │ url: "https://pub.dartlang.org"
140 │ │ source: hosted
141 │ │ version: "2.1.0"
142 │ │ http:
143 │ │ dependency: transitive
144 │ │ description:
145 │ │ name: http
146 │ │ url: "https://pub.dartlang.org"
147 │ │ source: hosted
148 │ │ version: "0.13.3"
149 │ │ http_client_helper:
150 │ │ dependency: transitive
151 │ │ description:
152 │ │ name: http_client_helper
153 │ │ url: "https://pub.dartlang.org"
154 │ │ source: hosted
155 │ │ version: "2.0.2"
156 │ │ http_parser:
157 │ │ dependency: transitive
158 │ │ description:
159 │ │ name: http_parser
160 │ │ url: "https://pub.dartlang.org"
161 │ │ source: hosted
162 │ │ version: "4.0.0"
163 │ │ intl:
164 │ │ dependency: "direct main"
165 │ │ description:
166 │ │ name: intl
167 │ │ url: "https://pub.dartlang.org"
168 │ │ source: hosted
169 │ │ version: "0.17.0"
170 │ │ intro_slider:
171 │ │ dependency: "direct main"
172 │ │ description:
173 │ │ name: intro_slider
174 │ │ url: "https://pub.dartlang.org"
175 │ │ source: hosted
176 │ │ version: "2.4.3"
177 │ │ logger:
178 │ │ dependency: "direct main"
179 │ │ description:
180 │ │ name: logger
181 │ │ url: "https://pub.dartlang.org"
182 │ │ source: hosted
183 │ │ version: "1.0.0"
184 │ │ meta:
185 │ │ dependency: transitive
186 │ │ description:
187 │ │ name: meta
188 │ │ url: "https://pub.dartlang.org"
189 │ │ source: hosted
190 │ │ version: "1.3.0"
191 │ │ path:
192 │ │ dependency: transitive
193 │ │ description:
194 │ │ name: path
195 │ │ url: "https://pub.dartlang.org"
196 │ │ source: hosted
197 │ │ version: "1.8.0"
198 │ │ path_provider:
199 │ │ dependency: transitive
200 │ │ description:
201 │ │ name: path_provider
202 │ │ url: "https://pub.dartlang.org"
203 │ │ source: hosted
204 │ │ version: "2.0.1"
205 │ │ path_provider_linux:
206 │ │ dependency: transitive
207 │ │ description:
208 │ │ name: path_provider_linux
209 │ │ url: "https://pub.dartlang.org"
210 │ │ source: hosted
211 │ │ version: "2.0.0"
212 │ │ path_provider_macos:
213 │ │ dependency: transitive
214 │ │ description:
215 │ │ name: path_provider_macos
216 │ │ url: "https://pub.dartlang.org"
217 │ │ source: hosted
218 │ │ version: "2.0.0"
219 │ │ path_provider_platform_interface:
220 │ │ dependency: transitive
221 │ │ description:
222 │ │ name: path_provider_platform_interface
223 │ │ url: "https://pub.dartlang.org"
224 │ │ source: hosted
225 │ │ version: "2.0.1"
226 │ │ path_provider_windows:
227 │ │ dependency: transitive
228 │ │ description:
229 │ │ name: path_provider_windows
230 │ │ url: "https://pub.dartlang.org"
231 │ │ source: hosted
232 │ │ version: "2.0.1"
233 │ │ pedantic:
234 │ │ dependency: "direct main"
235 │ │ description:
236 │ │ name: pedantic
237 │ │ url: "https://pub.dartlang.org"
238 │ │ source: hosted
239 │ │ version: "1.11.0"
240 │ │ platform:
241 │ │ dependency: transitive
242 │ │ description:
243 │ │ name: platform
244 │ │ url: "https://pub.dartlang.org"
245 │ │ source: hosted
246 │ │ version: "3.0.0"
247 │ │ plugin_platform_interface:
248 │ │ dependency: transitive
249 │ │ description:
250 │ │ name: plugin_platform_interface
251 │ │ url: "https://pub.dartlang.org"
252 │ │ source: hosted
253 │ │ version: "2.0.0"
254 │ │ pointycastle:
255 │ │ dependency: transitive
256 │ │ description:
257 │ │ name: pointycastle
258 │ │ url: "https://pub.dartlang.org"
259 │ │ source: hosted
260 │ │ version: "3.0.1"
261 │ │ process:
262 │ │ dependency: transitive
263 │ │ description:
264 │ │ name: process
265 │ │ url: "https://pub.dartlang.org"
266 │ │ source: hosted
267 │ │ version: "4.2.1"
268 │ │ sky_engine:
269 │ │ dependency: transitive
270 │ │ description: flutter
271 │ │ source: sdk
272 │ │ version: "0.0.99"
273 │ │ source_span:
274 │ │ dependency: transitive
275 │ │ description:
276 │ │ name: source_span
277 │ │ url: "https://pub.dartlang.org"
278 │ │ source: hosted
279 │ │ version: "1.8.1"
280 │ │ string_scanner:
281 │ │ dependency: transitive
282 │ │ description:
283 │ │ name: string_scanner
284 │ │ url: "https://pub.dartlang.org"
285 │ │ source: hosted
286 │ │ version: "1.1.0"
287 │ │ term_glyph:
288 │ │ dependency: transitive
289 │ │ description:
290 │ │ name: term_glyph
291 │ │ url: "https://pub.dartlang.org"
292 │ │ source: hosted
293 │ │ version: "1.2.0"
294 │ │ timeago:
295 │ │ dependency: "direct main"
296 │ │ description:
297 │ │ name: timeago
298 │ │ url: "https://pub.dartlang.org"
299 │ │ source: hosted
300 │ │ version: "3.0.2"
301 │ │ typed_data:
302 │ │ dependency: transitive
303 │ │ description:
304 │ │ name: typed_data
305 │ │ url: "https://pub.dartlang.org"
306 │ │ source: hosted
307 │ │ version: "1.3.0"
308 │ │ vector_math:
309 │ │ dependency: transitive
310 │ │ description:
311 │ │ name: vector_math
312 │ │ url: "https://pub.dartlang.org"
313 │ │ source: hosted
314 │ │ version: "2.1.0"
315 │ │ win32:
316 │ │ dependency: transitive
317 │ │ description:
318 │ │ name: win32
319 │ │ url: "https://pub.dartlang.org"
320 │ │ source: hosted
321 │ │ version: "2.0.5"
322 │ │ xdg_directories:
323 │ │ dependency: transitive
324 │ │ description:
325 │ │ name: xdg_directories
326 │ │ url: "https://pub.dartlang.org"
327 │ │ source: hosted
328 │ │ version: "0.2.0"
329 │ │ sdks:
330 │ │ dart: ">=2.12.0 <3.0.0"
331 │ └ flutter: ">=1.20.0"
╵
pub get failed (65; ╵)
exit code 65
你能帮我解决它吗? 我使用带有 m1 芯片的 MacBook Air。我运行了许多 Flutter 项目,没有任何问题。
颤振医生 -v [✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.1 20G80 darwin-arm, locale en-KW) • Flutter 2.2.3 版,位于 /Users/mac/FlutterDev/flutter • 框架修订 f4abaa0735(7 周前),2021-07-01 12:46:11 -0700 • 引擎版本 241c87ad80 • Dart 版本 2.13.4
[✓] android 工具链 - 为 Android 设备开发(Android SDK 版本 31.0.0) • Android SDK 位于 /Users/mac/Library/Android/sdk • 平台 android-31,构建工具 31.0.0 • Java 二进制文件位于:/Applications/Android Studio Preview.app/Contents/jre/jdk/Contents/Home/bin/java • Java 版 OpenJDK 运行时环境(内部版本 11.0.10+0-b96-7281165) • 接受所有 Android 许可证。
[✓] Xcode - 为 ios 和 macOS 开发 • Xcode 位于 /Applications/Xcode.app/Contents/Developer • Xcode 12.5.1,内部版本 12E507 • CocoaPods 版本 1.10.2
[✓] Chrome - 为网络开发 • Chrome 位于 /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio • Android Studio 位于 /Applications/Android Studio Preview.app/Contents • Flutter 插件可以从以下位置安装: ??? https://plugins.jetbrains.com/plugin/9212-flutter • Dart 插件可以从以下位置安装: ??? https://plugins.jetbrains.com/plugin/6351-dart • Java 版 OpenJDK 运行时环境(内部版本 11.0.10+0-b96-7281165)
[✓] 已连接设备(2 个可用) • macOS(桌面) • macos • darwin-arm64 • macOS 11.5.1 20G80 darwin-arm • Chrome(网络) • chrome • web-javascript • Google Chrome 92.0.4515.159
• 未发现任何问题!
【问题讨论】:
【参考方案1】:删除您的 pubspec.lock 文件并再次运行 flutter pub get
。
【讨论】:
你能分享你的 pubspec.yaml 文件吗?以上是关于pubspec.lock 的第 3 行第 1 列出错:只需要一个文档的主要内容,如果未能解决你的问题,请参考以下文章
Flutter工程代码管理 pubspec.yaml.packages 与 pubspec.lock文件的来龙去脉
在 Dart 和 Pub 中,我应该将 pubspec.lock 添加到我的 .gitignore 吗?