无法读取未定义的属性“编译”。无法启动新的本机项目

时间:2018-11-25 22:36:26

标签: node.js reactjs react-native npm

我正在关注React Native网站上的Getting Started部分。我无法启动使用expo init Project2命令生成的应用。这就是我运行npm start

后得到的结果
Pawes-MacBook-Pro:Project2 pawel$ npm start

> empty-project-template@ start /Users/pawel/Projects/react/Project2
> expo start

[23:31:11] Starting project at /Users/pawel/Projects/react/Project2
[23:31:11] Expo DevTools is running at http://localhost:19002
[23:31:11] Opening DevTools in the browser... (press shift-d to disable)
[23:31:14] TypeError: Cannot read property 'compile' of undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! empty-project-template@ start: `expo start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the empty-project-template@ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/pawel/.npm/_logs/2018-11-25T22_31_14_188Z-debug.log

完整debug.log

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@6.4.1
3 info using node@v10.13.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle empty-project-template@~prestart: empty-project-template@
6 info lifecycle empty-project-template@~start: empty-project-template@
7 verbose lifecycle empty-project-template@~start: unsafe-perm in lifecycle true
8 verbose lifecycle empty-project-template@~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/pawel/Projects/react/Project2/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
9 verbose lifecycle empty-project-template@~start: CWD: /Users/pawel/Projects/react/Project2
10 silly lifecycle empty-project-template@~start: Args: [ '-c', 'expo start' ]
11 silly lifecycle empty-project-template@~start: Returned: code: 1  signal: null
12 info lifecycle empty-project-template@~start: Failed to exec start script
13 verbose stack Error: empty-project-template@ start: `expo start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:182:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:182:13)
13 verbose stack     at maybeClose (internal/child_process.js:962:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
14 verbose pkgid empty-project-template@
15 verbose cwd /Users/pawel/Projects/react/Project2
16 verbose Darwin 17.7.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
18 verbose node v10.13.0
19 verbose npm  v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error empty-project-template@ start: `expo start`
22 error Exit status 1
23 error Failed at the empty-project-template@ start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Expo开发人员工具在我的Chrome上打开,但显示以下消息:Expo Developer Tools is disconnected from Expo CLI. Use the expo start command to start the CLI again.

当我尝试使用expo start命令(而不是npm start)时,会得到类似的结果,但是CLI输出略微不够

Pawes-MacBook-Pro:Project2 pawel$ expo start
[23:32:52] Starting project at /Users/pawel/Projects/react/Project2
[23:32:52] Expo DevTools is running at http://localhost:19002
[23:32:52] Opening DevTools in the browser... (press shift-d to disable)
[23:32:55] TypeError: Cannot read property 'compile' of undefined

1 个答案:

答案 0 :(得分:0)

TL; DR :重新安装export function uniqueUserNameValidation(): AsyncValidatorFn { const commonsService = InjectorInstance.get<CommonsService>(CommonsService); return (c: AbstractControl): Promise < ValidationErrors | null > | Observable < ValidationErrors | null > => { return commonsService.uniqueUserName(c.value).pipe( map(data => { return data && data.status ? { 'uniqueValidation': true } : null }) ) } } 安装(例如,运行expo-cli),问题已解决。


在创建描述问题的the first issue之前的4小时内,npm un -g expo-cli && npm i -g expo-cli软件包的新版本已发布(joi)。 14.3.0 uses Joi来验证传递给expo-cli函数的某些选项参数。但是,constructUrlAsync不是直接使用expo-cli,不是it was wrappedjoi.validate

this commit登陆promisify并首次发布于joi时,它中断了与joi@14.3.0的集成。显然,这也打破了promisify的依赖性,从而又打破了xdl

我们已经hotfixedexpo-cli依赖项要求从joi更改为^14.0.4并发布14.0.4的问题。真正的解决方案来自this pull request,删除了用expo-cli@2.4.1包装joi.validate的过程。