如何停止咕噜咕噜的警报声(How to stop grunt watch's alert sound)
我仍然熟悉grunt以及它可以做什么,目前正在另一个开发人员的AngularJS项目上,每次我在控制器中进行更改时,浏览器页面会自动刷新并生成此警报窗口音频,有耳机在你可以想象每次我对代码进行简单的更改时,这会导致不适。
我相信它是由grunt的手表引起的,所以这是我的
Gruntfile.js
一部分:// Watches files for changes and runs tasks based on the changed files watch: { bower: { files: ['bower.json'], tasks: ['wiredep'] }, js: { files: ['<%= yeoman.app %>/scripts/{,*/}*.js', // Exclude disabled file, start with _. Or folder start with _ '!<%= yeoman.app %>/**/_*/*.js', '!<%= yeoman.app %>/**/_*.js' ], tasks: ['newer:jshint:all'], options: { livereload: '<%= connect.options.livereload %>' } }, jsTest: { files: ['test/spec/{,*/}*.js'], tasks: ['newer:jshint:test', 'karma'] }, styles: { files: ['<%= yeoman.app %>/styles/{,*/}*.css', '<%= yeoman.app %>/styles/{,*/}*.less'],// Change for LESS tasks: ['newer:recess', 'newer:copy:styles', 'autoprefixer'] }, gruntfile: { files: ['Gruntfile.js'] }, livereload: { options: { livereload: '<%= connect.options.livereload %>' }, files: [ '<%= yeoman.app %>/{,*/}*.html', '.tmp/styles/{,*/}*.css', '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}' ] } },
我可以在
Gruntfile.js
中写什么来阻止播放声音?更新:添加我的所有gruntfile
// Generated on 2015-03-31 using generator-angular 0.11.0 'use strict'; // # Globbing // for performance reasons we're only matching one level down: // 'test/spec/{,*/}*.js' // use this if you want to recursively match all subfolders: // 'test/spec/**/*.js' module.exports = function (grunt) { // Load grunt tasks automatically require('load-grunt-tasks')(grunt); // Time how long tasks take. Can help when optimizing build times require('time-grunt')(grunt); // Configurable paths for the application var appConfig = { app: require('./bower.json').appPath || 'app', dist: 'dist' }; // Define the configuration for all the tasks grunt.initConfig({ // Project settings yeoman: appConfig, // Watches files for changes and runs tasks based on the changed files watch: { bower: { files: ['bower.json'], tasks: ['wiredep'] }, js: { files: ['<%= yeoman.app %>/scripts/{,*/}*.js', // Exclude disabled file, start with _. Or folder start with _ '!<%= yeoman.app %>/**/_*/*.js', '!<%= yeoman.app %>/**/_*.js' ], tasks: ['newer:jshint:all'], options: { livereload: '<%= connect.options.livereload %>' } }, jsTest: { files: ['test/spec/{,*/}*.js'], tasks: ['newer:jshint:test', 'karma'] }, styles: { files: ['<%= yeoman.app %>/styles/{,*/}*.css', '<%= yeoman.app %>/styles/{,*/}*.less'],// Change for LESS tasks: ['newer:recess', 'newer:copy:styles', 'autoprefixer'] }, gruntfile: { files: ['Gruntfile.js'] }, livereload: { options: { livereload: '<%= connect.options.livereload %>' }, files: [ '<%= yeoman.app %>/{,*/}*.html', '.tmp/styles/{,*/}*.css', '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}' ] } }, // The actual grunt server settings connect: { options: { port: 9000, // Change this to '0.0.0.0' to access the server from outside. localhost hostname: 'localhost', livereload: 35729 }, livereload: { options: { open: true, middleware: function (connect) { return [ connect.static('.tmp'), connect().use( '/bower_components', connect.static('./bower_components') ), connect.static(appConfig.app) ]; } } }, test: { options: { port: 9001, middleware: function (connect) { return [ connect.static('.tmp'), connect.static('test'), connect().use( '/bower_components', connect.static('./bower_components') ), connect.static(appConfig.app) ]; } } }, dist: { options: { open: true, base: '<%= yeoman.dist %>' } } }, // Make sure code styles are up to par and there are no obvious mistakes jshint: { options: { jshintrc: '.jshintrc', reporter: require('jshint-stylish') }, all: { src: [ 'Gruntfile.js', '<%= yeoman.app %>/scripts/{,*/}*.js', '!<%= yeoman.app %>/**/_*/*.js', // Exclude '!<%= yeoman.app %>/**/_*.js' ] }, test: { options: { jshintrc: 'test/.jshintrc' }, src: ['test/spec/{,*/}*.js'] } }, // Empties folders to start fresh clean: { dist: { files: [{ dot: true, src: [ '.tmp', '<%= yeoman.dist %>/{,*/}*', '!<%= yeoman.dist %>/.git{,*/}*' ] }] }, server: '.tmp' }, // Add vendor prefixed styles autoprefixer: { options: { browsers: ['last 1 version'] }, dist: { files: [{ expand: true, cwd: '.tmp/styles/', src: '{,*/}*.css', dest: '.tmp/styles/' }] } }, // Automatically inject Bower components into the app wiredep: { app: { src: ['<%= yeoman.app %>/index.html'], ignorePath: /\.\.\// }, test: { devDependencies: true, src: '<%= karma.unit.configFile %>', ignorePath: /\.\.\//, fileTypes:{ js: { block: /(([\s\t]*)\/{2}\s*?bower:\s*?(\S*))(\n|\r|.)*?(\/{2}\s*endbower)/gi, detect: { js: /'(.*\.js)'/gi }, replace: { js: '\'{{filePath}}\',' } } } } }, // Renames files for browser caching purposes filerev: { dist: { src: [ '<%= yeoman.dist %>/scripts/{,*/}*.js', '<%= yeoman.dist %>/styles/{,*/}*.css', //'<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}', '<%= yeoman.dist %>/styles/fonts/*' ] } }, // Reads HTML for usemin blocks to enable smart builds that automatically // concat, minify and revision files. Creates configurations in memory so // additional tasks can operate on them useminPrepare: { html: '<%= yeoman.app %>/index.html', js: { src: ['index.html', 'another.html'] }, options: { dest: '<%= yeoman.dist %>', flow: { html: { steps: { js: ['concat', 'uglifyjs'], css: ['cssmin'] }, post: {} } } } }, // Performs rewrites based on filerev and the useminPrepare configuration usemin: { html: ['<%= yeoman.dist %>/{,*/}*.html'], css: ['<%= yeoman.dist %>/styles/{,*/}*.css'], options: { assetsDirs: [ '<%= yeoman.dist %>', '<%= yeoman.dist %>/images', '<%= yeoman.dist %>/styles' ] } }, // The following *-min tasks will produce minified files in the dist folder // By default, your `index.html`'s <!-- Usemin block --> will take care of // minification. These next options are pre-configured if you do not wish // to use the Usemin blocks. // cssmin: { // dist: { // files: { // '<%= yeoman.dist %>/styles/main.css': [ // '.tmp/styles/{,*/}*.css' // ] // } // } // }, // uglify: { // dist: { // files: { // '<%= yeoman.dist %>/scripts/scripts.js': [ // '<%= yeoman.dist %>/scripts/scripts.js' // ] // } // } // }, // concat: { // dist: {} // }, imagemin: { dist: { files: [{ expand: true, cwd: '<%= yeoman.app %>/images', src: '{,*/}*.{png,jpg,jpeg,gif}', dest: '<%= yeoman.dist %>/images' }] } }, svgmin: { dist: { files: [{ expand: true, cwd: '<%= yeoman.app %>/images', src: '{,*/}*.svg', dest: '<%= yeoman.dist %>/images' }] } }, htmlmin: { dist: { options: { collapseWhitespace: true, conservativeCollapse: true, collapseBooleanAttributes: true, removeCommentsFromCDATA: true, removeOptionalTags: true }, files: [{ expand: true, cwd: '<%= yeoman.dist %>', src: ['*.html', 'views/{,*/}*.html', 'scripts/modules/{,*/}*.html'],//SLM added for minify module html templates dest: '<%= yeoman.dist %>' }] } }, // ng-annotate tries to make the code safe for minification automatically // by using the Angular long form for dependency injection. ngAnnotate: { dist: { files: [{ expand: true, cwd: '.tmp/concat/scripts', src: ['*.js', '!oldieshim.js'], dest: '.tmp/concat/scripts' }] } }, // Replace Google CDN references cdnify: { dist: { html: ['<%= yeoman.dist %>/*.html'] } }, // Copies remaining files to places other tasks can use copy: { dist: { files: [{ expand: true, dot: true, cwd: '<%= yeoman.app %>', dest: '<%= yeoman.dist %>', src: [ '*.{ico,png,txt}', '.htaccess', '*.html', 'content/*.json', 'views/{,*/}*.html', 'scripts/modules/{,*/}*.html', '!**/_*/*.html', // Exclude '!**/_*.html', 'images/{,*/}*.{webp}', 'styles/fonts/{,*/}*.*' ] }, { expand: true, cwd: '.tmp/images', dest: '<%= yeoman.dist %>/images', src: ['generated/*'] }, { expand: true, cwd: 'bower_components/bootstrap/dist', src: 'fonts/*', dest: '<%= yeoman.dist %>' }] }, styles: { expand: true, cwd: '<%= yeoman.app %>/styles', dest: '.tmp/styles/', // src: '{,*/}*.css' src: 'page.css' // Only copy page.css, since that's the all combined file build up by LESS } }, // Change for LESS move and compress less into css file recess: { dist: { options: { compile: true }, files: [ { expand: true, // Enable dynamic expansion. cwd: '<%= yeoman.app %>/styles/less', // Src matches are relative to this path. src: ['{,*/}*.less'], // Actual pattern(s) to match. dest: '<%= yeoman.app %>/styles', // Destination path prefix. ext: '.css', // Dest filepaths will have this extension. }, ] } }, // Run some tasks in parallel to speed up the build process concurrent: { server: [ 'copy:styles' ], test: [ 'copy:styles' ], dist: [ 'copy:styles', 'imagemin', 'svgmin' ] }, // Test settings karma: { unit: { configFile: 'test/karma.conf.js', singleRun: true } }, // Strip test code, particularly console.log or log strip_code: { options: { // Task-specific options patterns: [/log\(\)/g, / *console\.log\([\w\S ]+\);?\n?/g, / *console\.error\([\w\S ]+\);?\n?/g] }, your_target: { src: '.tmp/concat/scripts/*.js' }, } }); // Let's see if it load up properly. grunt.loadNpmTasks('grunt-contrib-less'); grunt.loadNpmTasks('grunt-strip-code'); // Daily development task grunt.registerTask('serve', 'Compile then start a connect web server', function (target) { if (target === 'dist') { return grunt.task.run(['build', 'connect:dist:keepalive']); } grunt.task.run([ 'clean:server', 'wiredep', 'recess:dist', 'concurrent:server', 'autoprefixer', 'connect:livereload', 'watch' ]); }); grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) { grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.'); grunt.task.run(['serve:' + target]); }); // Not currently in use, just kept here as reference grunt.registerTask('test', [ 'clean:server', 'wiredep:test', 'recess', 'concurrent:test', 'autoprefixer', 'connect:test', 'karma' ]); // Production build - for development or production uploading version both grunt.registerTask('build', [ 'clean:dist', 'wiredep', 'recess', 'useminPrepare', 'concurrent:dist', 'autoprefixer', 'concat', 'ngAnnotate', 'copy:dist', 'cdnify', 'cssmin', 'uglify', 'filerev', 'usemin', 'htmlmin' ]); // Production build, one more task to trim all console line for debugging // Recommanded for production upload // IMPORTANT! Using module 'highcharts-ng' will screw the strip_code. grunt.registerTask('build-pro', [ 'clean:dist', 'wiredep', 'recess', 'useminPrepare', 'concurrent:dist', 'autoprefixer', 'concat', 'ngAnnotate', 'copy:dist', 'cdnify', 'cssmin', 'strip_code', 'uglify', 'filerev', 'usemin', 'htmlmin' ]); grunt.registerTask('default', [ 'newer:jshint', 'test', 'build' ]); };
I'm still getting familiar with grunt and what it can do and am currently on another developer's AngularJS project, each time I make a change in the controllers the browser page automatically refreshes and it produces this alert windows audio, having earphones in you can imagine the discomfort this causes each time I do a simple change in the code.
I believe it's caused by grunt's watch, so here is that part of my
Gruntfile.js
:// Watches files for changes and runs tasks based on the changed files watch: { bower: { files: ['bower.json'], tasks: ['wiredep'] }, js: { files: ['<%= yeoman.app %>/scripts/{,*/}*.js', // Exclude disabled file, start with _. Or folder start with _ '!<%= yeoman.app %>/**/_*/*.js', '!<%= yeoman.app %>/**/_*.js' ], tasks: ['newer:jshint:all'], options: { livereload: '<%= connect.options.livereload %>' } }, jsTest: { files: ['test/spec/{,*/}*.js'], tasks: ['newer:jshint:test', 'karma'] }, styles: { files: ['<%= yeoman.app %>/styles/{,*/}*.css', '<%= yeoman.app %>/styles/{,*/}*.less'],// Change for LESS tasks: ['newer:recess', 'newer:copy:styles', 'autoprefixer'] }, gruntfile: { files: ['Gruntfile.js'] }, livereload: { options: { livereload: '<%= connect.options.livereload %>' }, files: [ '<%= yeoman.app %>/{,*/}*.html', '.tmp/styles/{,*/}*.css', '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}' ] } },
What can I write in
Gruntfile.js
that would stop that sound from playing?.Update: Adding all of my gruntfile
// Generated on 2015-03-31 using generator-angular 0.11.0 'use strict'; // # Globbing // for performance reasons we're only matching one level down: // 'test/spec/{,*/}*.js' // use this if you want to recursively match all subfolders: // 'test/spec/**/*.js' module.exports = function (grunt) { // Load grunt tasks automatically require('load-grunt-tasks')(grunt); // Time how long tasks take. Can help when optimizing build times require('time-grunt')(grunt); // Configurable paths for the application var appConfig = { app: require('./bower.json').appPath || 'app', dist: 'dist' }; // Define the configuration for all the tasks grunt.initConfig({ // Project settings yeoman: appConfig, // Watches files for changes and runs tasks based on the changed files watch: { bower: { files: ['bower.json'], tasks: ['wiredep'] }, js: { files: ['<%= yeoman.app %>/scripts/{,*/}*.js', // Exclude disabled file, start with _. Or folder start with _ '!<%= yeoman.app %>/**/_*/*.js', '!<%= yeoman.app %>/**/_*.js' ], tasks: ['newer:jshint:all'], options: { livereload: '<%= connect.options.livereload %>' } }, jsTest: { files: ['test/spec/{,*/}*.js'], tasks: ['newer:jshint:test', 'karma'] }, styles: { files: ['<%= yeoman.app %>/styles/{,*/}*.css', '<%= yeoman.app %>/styles/{,*/}*.less'],// Change for LESS tasks: ['newer:recess', 'newer:copy:styles', 'autoprefixer'] }, gruntfile: { files: ['Gruntfile.js'] }, livereload: { options: { livereload: '<%= connect.options.livereload %>' }, files: [ '<%= yeoman.app %>/{,*/}*.html', '.tmp/styles/{,*/}*.css', '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}' ] } }, // The actual grunt server settings connect: { options: { port: 9000, // Change this to '0.0.0.0' to access the server from outside. localhost hostname: 'localhost', livereload: 35729 }, livereload: { options: { open: true, middleware: function (connect) { return [ connect.static('.tmp'), connect().use( '/bower_components', connect.static('./bower_components') ), connect.static(appConfig.app) ]; } } }, test: { options: { port: 9001, middleware: function (connect) { return [ connect.static('.tmp'), connect.static('test'), connect().use( '/bower_components', connect.static('./bower_components') ), connect.static(appConfig.app) ]; } } }, dist: { options: { open: true, base: '<%= yeoman.dist %>' } } }, // Make sure code styles are up to par and there are no obvious mistakes jshint: { options: { jshintrc: '.jshintrc', reporter: require('jshint-stylish') }, all: { src: [ 'Gruntfile.js', '<%= yeoman.app %>/scripts/{,*/}*.js', '!<%= yeoman.app %>/**/_*/*.js', // Exclude '!<%= yeoman.app %>/**/_*.js' ] }, test: { options: { jshintrc: 'test/.jshintrc' }, src: ['test/spec/{,*/}*.js'] } }, // Empties folders to start fresh clean: { dist: { files: [{ dot: true, src: [ '.tmp', '<%= yeoman.dist %>/{,*/}*', '!<%= yeoman.dist %>/.git{,*/}*' ] }] }, server: '.tmp' }, // Add vendor prefixed styles autoprefixer: { options: { browsers: ['last 1 version'] }, dist: { files: [{ expand: true, cwd: '.tmp/styles/', src: '{,*/}*.css', dest: '.tmp/styles/' }] } }, // Automatically inject Bower components into the app wiredep: { app: { src: ['<%= yeoman.app %>/index.html'], ignorePath: /\.\.\// }, test: { devDependencies: true, src: '<%= karma.unit.configFile %>', ignorePath: /\.\.\//, fileTypes:{ js: { block: /(([\s\t]*)\/{2}\s*?bower:\s*?(\S*))(\n|\r|.)*?(\/{2}\s*endbower)/gi, detect: { js: /'(.*\.js)'/gi }, replace: { js: '\'{{filePath}}\',' } } } } }, // Renames files for browser caching purposes filerev: { dist: { src: [ '<%= yeoman.dist %>/scripts/{,*/}*.js', '<%= yeoman.dist %>/styles/{,*/}*.css', //'<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}', '<%= yeoman.dist %>/styles/fonts/*' ] } }, // Reads HTML for usemin blocks to enable smart builds that automatically // concat, minify and revision files. Creates configurations in memory so // additional tasks can operate on them useminPrepare: { html: '<%= yeoman.app %>/index.html', js: { src: ['index.html', 'another.html'] }, options: { dest: '<%= yeoman.dist %>', flow: { html: { steps: { js: ['concat', 'uglifyjs'], css: ['cssmin'] }, post: {} } } } }, // Performs rewrites based on filerev and the useminPrepare configuration usemin: { html: ['<%= yeoman.dist %>/{,*/}*.html'], css: ['<%= yeoman.dist %>/styles/{,*/}*.css'], options: { assetsDirs: [ '<%= yeoman.dist %>', '<%= yeoman.dist %>/images', '<%= yeoman.dist %>/styles' ] } }, // The following *-min tasks will produce minified files in the dist folder // By default, your `index.html`'s <!-- Usemin block --> will take care of // minification. These next options are pre-configured if you do not wish // to use the Usemin blocks. // cssmin: { // dist: { // files: { // '<%= yeoman.dist %>/styles/main.css': [ // '.tmp/styles/{,*/}*.css' // ] // } // } // }, // uglify: { // dist: { // files: { // '<%= yeoman.dist %>/scripts/scripts.js': [ // '<%= yeoman.dist %>/scripts/scripts.js' // ] // } // } // }, // concat: { // dist: {} // }, imagemin: { dist: { files: [{ expand: true, cwd: '<%= yeoman.app %>/images', src: '{,*/}*.{png,jpg,jpeg,gif}', dest: '<%= yeoman.dist %>/images' }] } }, svgmin: { dist: { files: [{ expand: true, cwd: '<%= yeoman.app %>/images', src: '{,*/}*.svg', dest: '<%= yeoman.dist %>/images' }] } }, htmlmin: { dist: { options: { collapseWhitespace: true, conservativeCollapse: true, collapseBooleanAttributes: true, removeCommentsFromCDATA: true, removeOptionalTags: true }, files: [{ expand: true, cwd: '<%= yeoman.dist %>', src: ['*.html', 'views/{,*/}*.html', 'scripts/modules/{,*/}*.html'],//SLM added for minify module html templates dest: '<%= yeoman.dist %>' }] } }, // ng-annotate tries to make the code safe for minification automatically // by using the Angular long form for dependency injection. ngAnnotate: { dist: { files: [{ expand: true, cwd: '.tmp/concat/scripts', src: ['*.js', '!oldieshim.js'], dest: '.tmp/concat/scripts' }] } }, // Replace Google CDN references cdnify: { dist: { html: ['<%= yeoman.dist %>/*.html'] } }, // Copies remaining files to places other tasks can use copy: { dist: { files: [{ expand: true, dot: true, cwd: '<%= yeoman.app %>', dest: '<%= yeoman.dist %>', src: [ '*.{ico,png,txt}', '.htaccess', '*.html', 'content/*.json', 'views/{,*/}*.html', 'scripts/modules/{,*/}*.html', '!**/_*/*.html', // Exclude '!**/_*.html', 'images/{,*/}*.{webp}', 'styles/fonts/{,*/}*.*' ] }, { expand: true, cwd: '.tmp/images', dest: '<%= yeoman.dist %>/images', src: ['generated/*'] }, { expand: true, cwd: 'bower_components/bootstrap/dist', src: 'fonts/*', dest: '<%= yeoman.dist %>' }] }, styles: { expand: true, cwd: '<%= yeoman.app %>/styles', dest: '.tmp/styles/', // src: '{,*/}*.css' src: 'page.css' // Only copy page.css, since that's the all combined file build up by LESS } }, // Change for LESS move and compress less into css file recess: { dist: { options: { compile: true }, files: [ { expand: true, // Enable dynamic expansion. cwd: '<%= yeoman.app %>/styles/less', // Src matches are relative to this path. src: ['{,*/}*.less'], // Actual pattern(s) to match. dest: '<%= yeoman.app %>/styles', // Destination path prefix. ext: '.css', // Dest filepaths will have this extension. }, ] } }, // Run some tasks in parallel to speed up the build process concurrent: { server: [ 'copy:styles' ], test: [ 'copy:styles' ], dist: [ 'copy:styles', 'imagemin', 'svgmin' ] }, // Test settings karma: { unit: { configFile: 'test/karma.conf.js', singleRun: true } }, // Strip test code, particularly console.log or log strip_code: { options: { // Task-specific options patterns: [/log\(\)/g, / *console\.log\([\w\S ]+\);?\n?/g, / *console\.error\([\w\S ]+\);?\n?/g] }, your_target: { src: '.tmp/concat/scripts/*.js' }, } }); // Let's see if it load up properly. grunt.loadNpmTasks('grunt-contrib-less'); grunt.loadNpmTasks('grunt-strip-code'); // Daily development task grunt.registerTask('serve', 'Compile then start a connect web server', function (target) { if (target === 'dist') { return grunt.task.run(['build', 'connect:dist:keepalive']); } grunt.task.run([ 'clean:server', 'wiredep', 'recess:dist', 'concurrent:server', 'autoprefixer', 'connect:livereload', 'watch' ]); }); grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) { grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.'); grunt.task.run(['serve:' + target]); }); // Not currently in use, just kept here as reference grunt.registerTask('test', [ 'clean:server', 'wiredep:test', 'recess', 'concurrent:test', 'autoprefixer', 'connect:test', 'karma' ]); // Production build - for development or production uploading version both grunt.registerTask('build', [ 'clean:dist', 'wiredep', 'recess', 'useminPrepare', 'concurrent:dist', 'autoprefixer', 'concat', 'ngAnnotate', 'copy:dist', 'cdnify', 'cssmin', 'uglify', 'filerev', 'usemin', 'htmlmin' ]); // Production build, one more task to trim all console line for debugging // Recommanded for production upload // IMPORTANT! Using module 'highcharts-ng' will screw the strip_code. grunt.registerTask('build-pro', [ 'clean:dist', 'wiredep', 'recess', 'useminPrepare', 'concurrent:dist', 'autoprefixer', 'concat', 'ngAnnotate', 'copy:dist', 'cdnify', 'cssmin', 'strip_code', 'uglify', 'filerev', 'usemin', 'htmlmin' ]); grunt.registerTask('default', [ 'newer:jshint', 'test', 'build' ]); };
原文:https://stackoverflow.com/questions/41797302
最满意答案
我遇到了类似的问题,从这里找到了解决方案:
导航到
node_modules/react-native-maps/lib/android/build.gradle
,然后将compileOnly
更改为provided
和implementation
以进行compile
。我希望这有帮助。
I faced a similar issue and found the solution from here:
Navigate to
node_modules/react-native-maps/lib/android/build.gradle
and then changecompileOnly
toprovided
andimplementation
tocompile
.I hope this helps.
相关问答
更多-
在react-native-maps上要求未知模块“undefined”(Requiring unknown module “undefined” on react-native-maps)[2023-07-29]
尝试将你的package.json "react-native-maps": "^0.20.1"为这个“react-native-maps”:“ https://github.com/react-community/react-native-maps .git “`以确保您将使用此处建议的主分支https://github.com/react-community/react-native-maps/issues/2051#issuecomment-371530715 Try changing this fr ... -
如果您想使用没有人编写React Native组件的本React Native组件,您将自己完成。 对大多数事情来说并不是很难。 您可以在链接的文档中学习如何为iOS和Android执行此操作。 If you want to use a native component that nobody wrote a React Native component for, you will to do it yourself. It's not very hard for most things. You can ...
-
Map组件没有得到可用于确定其大小的任何属性。 因此,它是0x0像素大,不被看到。 为了解决这个问题,你需要将这些属性中的一个添加到styles.map : 柔性 高度宽度 右侧和底部 The Map component does not get any properties which may be used to determine its size. Therefore it is 0x0 pixel big and not to be seen. In order to fix this you n ...
-
本机无法安装react-native-maps(Android)(react native can't install react-native-maps (Android))[2022-12-07]
我在refit-native-maps项目的git hub上发布了一个问题,并在那里得到了解决方案。 对于那些有相同问题的人,我的解决方案是更改android / settings.gradle的说明缺少/ lib / 这给出了: include ':react-native-maps' project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/ ... -
尝试使用较旧的反应原生版本来安装您的项目。 react-native init --version="0.54.0" MyMap 这可能有助于: New React Native项目与旧版本的反应原生 Try installing your project with older react-native version. react-native init --version="0.54.0" MyMap this might help: New React Native project with old ...
-
React-Native:获取react-native-maps的旋转角度(React-Native: Get rotation angle of react-native-maps)[2022-04-15]
你有没有试过Marker flat道具? https://github.com/react-community/react-native-maps/blob/master/docs/marker.md Have you tried flat prop of Marker? https://github.com/react-community/react-native-maps/blob/master/docs/marker.md -
在iOS上反应native-react-native-maps的性能变慢(react native - react-native-maps performance slow on iOS)[2022-04-18]
因此,我认为可能会困扰您的代码中有一些我不喜欢的内容: 在iOS中使用Google提供者:是否安装? 正确工作? 我通常使用默认的iOS地图,因为我猜测是更优化的。 您正在onRegionChange中使用console.log(),可能会执行很多次。 我在Debug中遇到了一些iOS性能问题,因为我在渲染方法中使用了很多console.log(),这会降低模拟器速度。 看起来该地区正在指向该州的一个地区,并且您在移动时再次更新该地区。 所以,我会试试这个: 删除console.log或确保不在XCode中 ... -
我遇到了类似的问题,从这里找到了解决方案: 导航到node_modules/react-native-maps/lib/android/build.gradle ,然后将compileOnly更改为provided和implementation以进行compile 。 我希望这有帮助。 I faced a similar issue and found the solution from here: Navigate to node_modules/react-native-maps/lib/android ...
-
react-native - 如何使用react-native-maps显示地图(react-native - How to display map using react-native-maps)[2021-08-20]
跑 $react-native link 从项目根目录链接react-native-maps与您的项目。 (或者您可以按照此处列出的手动步骤进行操作: https : //github.com/airbnb/react-native-maps/blob/master/docs/installation.md#option-3-manually ) Run $react-native link from the project root directory to link the react-native ... -
Android开发需要在您的计算机上安装JDK。 您必须将环境变量JAVA_HOME为有效的JDK。 该错误可能是因为您的计算机上没有JDK。 尝试启动Android Studio并通过创建一个空项目来检查JDK是否在这里,转到File-> Project Structure并查看JDK位置。 Android development requires to have the JDK installed on your computer. You have to set the environment var ...