我使用我的操作系统 Windows 10 创建了一个示例项目;
安装包没有问题,然后我写了以下内容:
我按下了“Y”键,但它显示出错误信息。
expo init test
cd test
npm start
一切运行良好,我可以在手机上看到我的应用程序,而且我的package.json文件看起来也很正常;
{
"name": "empty-project-template",
"main": "node_modules/expo/AppEntry.js",
"private": true,
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"eject": "expo eject"
},
"dependencies": {
"expo": "^30.0.1",
"react": "16.3.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz",
}
}
但如果我想安装像“uuid”这样的包;
npm install uuid
安装包没有问题,然后我写了以下内容:
npm start
This command requires Expo CLI.
Do you want to install it globally [Y/n]?
我按下了“Y”键,但它显示出错误信息。
This command requires Expo CLI.
Do you want to install it globally [Y/n]? y
Installing the package 'expo-cli'...
events.js:183
throw er; // Unhandled 'error' event
^
Error: spawn npm ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
at onErrorNT (internal/child_process.js:362:16)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickCallback (internal/process/next_tick.js:181:9)
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 start
,我的项目就会崩溃,我用yarn
测试了这一步骤,结果和npm
一样,我错在哪里了?
expo init new-project
,但如果使用npm install
安装任何软件包后,它还会再次出现问题。 - redkont