我正在跟随React Native的走马路来开始创建应用程序,但是当我进入 “ npm start”一秒钟后,本地服务器关闭,我在cmd中收到以下错误:
C:\Users\olsta\AwesomeProject>npm start
> @ start C:\Users\olsta\AwesomeProject
> expo start
Starting project at C:\Users\olsta\AwesomeProject
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
error Invalid regular expression: /(.*\\__fixtures__\\.*|node_modules[\\\]react[\\\]dist[\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*\\__tests__\\.*)$/: Unterminated character class. Run CLI with --verbose flag for more details.
SyntaxError: Invalid regular expression: /(.*\\__fixtures__\\.*|node_modules[\\\]react[\\\]dist[\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*\\__tests__\\.*)$/: Unterminated character class
at new RegExp (<anonymous>)
at blacklist (C:\Users\olsta\AwesomeProject\node_modules\metro-config\src\defaults\blacklist.js:34:10)
at getBlacklistRE (C:\Users\olsta\AwesomeProject\node_modules\react-native\node_modules\@react-native-community\cli\build\tools\loadMetroConfig.js:66:59)
at getDefaultConfig (C:\Users\olsta\AwesomeProject\node_modules\react-native\node_modules\@react-native-community\cli\build\tools\loadMetroConfig.js:82:20)
at load (C:\Users\olsta\AwesomeProject\node_modules\react-native\node_modules\@react-native-community\cli\build\tools\loadMetroConfig.js:118:25)
at Object.runServer [as func] (C:\Users\olsta\AwesomeProject\node_modules\react-native\node_modules\@react-native-community\cli\build\commands\server\runServer.js:82:58)
at Command.handleAction (C:\Users\olsta\AwesomeProject\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:164:23)
at Command.listener (C:\Users\olsta\AwesomeProject\node_modules\commander\index.js:315:8)
at Command.emit (events.js:210:5)
at Command.parseArgs (C:\Users\olsta\AwesomeProject\node_modules\commander\index.js:651:12)
Metro Bundler process exited with code 1
Set EXPO_DEBUG=true in your env to view the stack trace.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start: `expo start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ start script.
代码日志为:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start'
1 verbose cli ]
2 info using npm@6.12.1
3 info using node@v12.13.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle @~prestart: @
6 info lifecycle @~start: @
7 verbose lifecycle @~start: unsafe-perm in lifecycle true
8 verbose lifecycle @~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\olsta\AwesomeProject\node_modules\.bin;C:\Python27\;C:\Python27\Scripts;C:\Python37\Scripts\;C:\Python37\;C:\Program Files\Python37\Scripts\;C:\Program Files\Python37\;C:\Users\olsta\Scripts\;C:\Users\olsta\;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\MATLAB\R2017a\runtime\win64;C:\Program Files\MATLAB\R2017a\bin;C:\Users\olsta\AppData\Local\Programs\Python\Python36-32\;C:\Python;C:\Program Files\ffmpeg\bin;C:\Python\Scripts;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Java\jdk-9.0.1\bin;C:\ProgramData\chocolatey\bin;C:\Users\olsta\AppData\Local\Julia-1.2.0\bin;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Users\olsta\AppData\Local\Programs\Python\Python37-32\Scripts\;C:\Users\olsta\AppData\Local\Programs\Python\Python37-32\;C:\Python\Scripts\;C:\Python\;C:\Users\olsta\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\ffmpeg\bin;C:\Users\olsta\AppData\Roaming\npm
9 verbose lifecycle @~start: CWD: C:\Users\olsta\AwesomeProject
10 silly lifecycle @~start: Args: [ '/d /s /c', 'expo start' ]
11 silly lifecycle @~start: Returned: code: 1 signal: null
12 info lifecycle @~start: Failed to exec start script
13 verbose stack Error: @ start: `expo start`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:210:5)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:210:5)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid @
15 verbose cwd C:\Users\olsta\AwesomeProject
16 verbose Windows_NT 10.0.17763
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v12.13.1
19 verbose npm v6.12.1
20 error code ELIFECYCLE
21 error errno 1
22 error @ start: `expo start`
22 error Exit status 1
23 error Failed at the @ start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
package.json如下:
{
"_from": "expo-cli",
"_id": "expo-cli@3.11.1",
"_inBundle": false,
"_integrity": "sha512-efLwUDLhn37+P06sxFzuszgRWssUVJOTlVab/w4hGYi0mYI/0weSHiZggA/NXJfdeLikZrTR7Wk5OChRPHyRiQ==",
"_location": "/expo-cli",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "expo-cli",
"name": "expo-cli",
"escapedName": "expo-cli",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER"
],
"_resolved": "https://registry.npmjs.org/expo-cli/-/expo-cli-3.11.1.tgz",
"_shasum": "ded8e248e2b08e26cb8e5ed057d9ff1927389251",
"_spec": "expo-cli",
"_where": "C:\\WINDOWS\\system32",
"bin": {
"expo": "./bin/expo.js",
"expo-cli": "./bin/expo.js"
},
"bugs": {
"url": "https://github.com/expo/expo-cli/issues"
},
"bundleDependencies": false,
"dependencies": {
"@expo/build-tools": "0.1.0-alpha.8",
"@expo/bunyan": "3.0.2",
"@expo/config": "^2.5.2",
"@expo/dev-tools": "^0.9.2",
"@expo/json-file": "^8.2.2",
"@expo/package-manager": "^0.0.1",
"@expo/simple-spinner": "1.0.2",
"@expo/spawn-async": "1.5.0",
"@expo/traveling-fastlane-darwin": "1.11.0",
"@expo/traveling-fastlane-linux": "1.11.0",
"@expo/xdl": "57.2.1",
"@types/cli-table": "^0.3.0",
"@types/untildify": "^3.0.0",
"ansi-regex": "^4.1.0",
"axios": "0.19.0",
"babel-runtime": "6.26.0",
"base32.js": "0.1.0",
"boxen": "4.1.0",
"chalk": "2.4.1",
"cli-table": "0.3.1",
"commander": "2.17.1",
"dateformat": "3.0.3",
"delay-async": "1.2.0",
"detect-indent": "^6.0.0",
"detect-newline": "^3.0.0",
"enquirer": "^2.3.2",
"envinfo": "5.10.0",
"es6-error": "3.2.0",
"expo-optimize": "^0.0.3",
"fs-extra": "6.0.1",
"getenv": "0.7.0",
"glob": "7.1.2",
"indent-string": "4.0.0",
"inflection": "^1.12.0",
"inquirer": "5.2.0",
"klaw-sync": "6.0.0",
"lodash": "4.17.15",
"match-require": "2.1.0",
"npm-package-arg": "6.1.0",
"open": "6.3.0",
"ora": "3.4.0",
"pacote": "9.3.0",
"pngjs": "3.4.0",
"progress": "2.0.0",
"qrcode-terminal": "0.11.0",
"request": "^2.88.0",
"semver": "5.5.0",
"slash": "1.0.0",
"source-map-support": "0.5.9",
"split": "1.0.1",
"targz": "^1.0.1",
"tempy": "^0.3.0",
"untildify": "3.0.3",
"validator": "10.5.0",
"wordwrap": "1.0.0"
},
"deprecated": false,
"description": "The command-line tool for creating and publishing Expo apps",
"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/preset-flow": "^7.0.0",
"@expo/babel-preset-cli": "^0.2.2",
"@types/ansi-regex": "^4.0.0",
"@types/dateformat": "^3.0.0",
"@types/inflection": "^1.5.28",
"@types/inquirer": "6.0.3",
"@types/klaw-sync": "^6.0.0",
"@types/npm-package-arg": "^6.1.0",
"@types/progress": "^2.0.3",
"@types/slash": "^2.0.0",
"@types/split": "^1.0.0",
"@types/wordwrap": "^1.0.0",
"gulp": "^4.0.0",
"gulp-babel": "^8.0.0",
"gulp-changed": "^1.3.0",
"gulp-plumber": "^1.1.0",
"gulp-sourcemaps": "^2.6.4",
"jest": "^24.9.0",
"pkg": "^4.2.1"
},
"engines": {
"node": ">=6.9.1"
},
"files": [
"build",
"bin"
],
"gitHead": "613642fe06827cc231405784b099cf71c29072df",
"homepage": "https://github.com/expo/expo-cli/tree/master/packages/expo-cli#readme",
"keywords": [
"expo",
"react-native"
],
"license": "MIT",
"main": "build/exp.js",
"name": "expo-cli",
"optionalDependencies": {
"@expo/traveling-fastlane-darwin": "1.11.0",
"@expo/traveling-fastlane-linux": "1.11.0"
},
"pkg": {
"scripts": "build/**/*.js"
},
"preferGlobal": true,
"repository": {
"type": "git",
"url": "git+https://github.com/expo/expo-cli.git",
"directory": "packages/expo-cli"
},
"scripts": {
"build": "tsc --noEmit && gulp build",
"clean": "rm -rf build ./tsconfig.tsbuildinfo",
"pkg": "pkg .",
"prepare": "yarn run clean && yarn run build",
"preversion": "node ./scripts/preversion.js",
"start": "yarn run prepare && yarn run watch",
"test": "jest",
"test:watch": "jest --watch",
"watch": "concurrently \"tsc --noEmit --watch\" \"gulp watch\""
},
"version": "3.11.1"
}
对不起,代码量很大,我不确定您需要什么帮助。关于类似的问题: 我试过了: 步骤1:$ npm缓存清理--force
第2步:通过$ rm -rf node_modules文件夹删除node_modules,或通过进入目录并右键单击>删除/移至回收站来手动删除它。另外,也删除package-lock.json文件。
第3步:npm安装
要重新开始,$ npm start 它对我不起作用,但我首先找不到package-lock.json文件。 版本: node.js-v12.13.1 npm-6.12.1 世博会-3.11.1
答案 0 :(得分:1)
您使用的节点版本(12.13.1)有问题。 从系统上卸载NodeJ,然后下载并安装NodeJS版本12.9.0 然后,您将不会面对您提到的问题。我和你有同样的问题。但是,它对我有用。